home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / inet / ien / ien-124 < prev    next >
Text File  |  1988-12-01  |  166KB  |  5,186 lines

  1.  
  2.  
  3. IEN:  124
  4.                                     
  5.                                     
  6.                                     
  7.                                     
  8.                                     
  9.                                     
  10.                                     
  11.                               DOD STANDARD
  12.                                     
  13.                      TRANSMISSION CONTROL PROTOCOL
  14.                                     
  15.                                     
  16.                                     
  17.                              December 1979
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.                               prepared for
  35.                                     
  36.                Defense Advanced Research Projects Agency
  37.                 Information Processing Techniques Office
  38.                          1400 Wilson Boulevard
  39.                        Arlington, Virginia  22209
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.                                    by
  48.  
  49.                      Information Sciences Institute
  50.                    University of Southern California
  51.                            4676 Admiralty Way
  52.                    Marina del Rey, California  90291
  53.  
  54. December 1979                                                           
  55.                                            Transmission Control Protocol
  56.  
  57.  
  58.  
  59.                            TABLE OF CONTENTS
  60.  
  61.     PREFACE ........................................................ iii
  62.  
  63. 1.  INTRODUCTION ..................................................... 1
  64.  
  65.   1.1  Motivation .................................................... 1
  66.   1.2  Scope ......................................................... 2
  67.   1.3  About This Document ........................................... 2
  68.   1.4  Interfaces .................................................... 3
  69.   1.5  Operation ..................................................... 3
  70.  
  71. 2.  PHILOSOPHY ....................................................... 7
  72.  
  73.   2.1  Elements of the Internetwork System ........................... 7
  74.   2.2  Model of Operation ............................................ 7
  75.   2.3  The Host Environment .......................................... 8
  76.   2.4  Interfaces .................................................... 9
  77.   2.5  Relation to Other Protocols ................................... 9
  78.   2.6  Reliable Communication ....................................... 10
  79.   2.7  Connection Establishment and Clearing ........................ 10
  80.   2.8  Data Communication ........................................... 12
  81.   2.9  Precedence and Security ...................................... 13
  82.   2.10 Robustness Principle ......................................... 13
  83.  
  84. 3.  FUNCTIONAL SPECIFICATION ........................................ 15
  85.  
  86.   3.1  Header Format ................................................ 15
  87.   3.2  Terminology .................................................. 19
  88.   3.3  Sequence Numbers ............................................. 24
  89.   3.4  Establishing a connection .................................... 29
  90.   3.5  Closing a Connection ......................................... 35
  91.   3.6  Precedence and Security ...................................... 38
  92.   3.7  Data Communication ........................................... 38
  93.   3.8  Interfaces ................................................... 42
  94.   3.9  Event Processing ............................................. 52
  95.  
  96. GLOSSARY ............................................................ 75
  97.  
  98. REFERENCES .......................................................... 83
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.                                                                 [Page i]
  111.  
  112.  
  113.                                                            December 1979
  114. Transmission Control Protocol
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. [Page ii]                                                               
  170.  
  171.  
  172. December 1979                                                           
  173.                                            Transmission Control Protocol
  174.  
  175.  
  176.  
  177.                                 PREFACE
  178.  
  179.  
  180.  
  181. This document describes the DoD Standard Transmission Control Protocol
  182. (TCP).  There have been seven earlier editions of the ARPA TCP
  183. specification on which this standard is based, and the present text
  184. draws heavily from them.  There have been many contributors to this work
  185. both in terms of concepts and in terms of text.  This edition
  186. incorporates the addition of security, compartmentation, and precedence
  187. concepts into the TCP specification.
  188.  
  189.                                                            Jon Postel
  190.  
  191.                                                            Editor
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.                                                               [Page iii]
  229.  
  230.  
  231. December 1979 
  232. IEN:124
  233. Replaces:  IENs 112,
  234. 81, 55, 44, 40, 27, 21, 5
  235.  
  236.                               DOD STANDARD
  237.  
  238.                      TRANSMISSION CONTROL PROTOCOL
  239.  
  240.  
  241.  
  242.                             1.  INTRODUCTION
  243.  
  244. The Transmission Control Protocol (TCP) is intended for use as a highly
  245. reliable host-to-host protocol between hosts in packet-switched computer
  246. communication networks, and especially in interconnected systems of such
  247. networks.
  248.  
  249. This document describes the functions to be performed by the
  250. Transmission Control Protocol, the program that implements it, and its
  251. interface to programs or users that require its services.
  252.  
  253. 1.1.  Motivation
  254.  
  255.   Computer communication systems are playing an increasingly important
  256.   role in military, government, and civilian environments.  This
  257.   document primarily focuses its attention on military computer
  258.   communication requirements, especially robustness in the presence of
  259.   communication unreliability and availability in the presence of
  260.   congestion, but many of these problems are found in the civilian and
  261.   government sector as well.
  262.  
  263.   As strategic and tactical computer communication networks are
  264.   developed and deployed, it is essential to provide means of
  265.   interconnecting them and to provide standard interprocess
  266.   communication protocols which can support a broad range of
  267.   applications.  In anticipation of the need for such standards, the
  268.   Deputy Undersecretary of Defense for Research and Engineering has
  269.   declared the Transmission Control Protocol (TCP) described herein to
  270.   be a basis for DoD-wide inter-process communication protocol
  271.   standardization.
  272.  
  273.   TCP is a connection-oriented, end-to-end reliable protocol designed to
  274.   fit into a layered hierarchy of protocols which support multi-network
  275.   applications.  The TCP provides for reliable inter-process
  276.   communication between pairs of processes in host computers attached to
  277.   distinct but interconnected computer communication networks.  Very few
  278.   assumptions are made as to the reliability of the communication
  279.   protocols below the TCP layer.  At most, the TCP assumes it can obtain
  280.   a simple, potentially unreliable datagram service from the lower level
  281.   protocols.  In principle, the TCP should be able to operate above a
  282.   wide spectrum of communication systems ranging from hard-wired
  283.   connections to packet-switched or circuit-switched networks.
  284.  
  285.  
  286.  
  287.                                                                 [Page 1]
  288.  
  289.  
  290.                                                            December 1979
  291. Transmission Control Protocol
  292. Introduction
  293.  
  294.  
  295.  
  296.   The TCP fits into a layered protocol architecture just above a basic
  297.   Internet Protocol [1] which provides a way for the TCP to send and
  298.   receive variable-length segments of information enclosed in internet
  299.   datagram "envelopes".  The internet datagram provides a means for
  300.   addressing source and destination TCPs in different networks, and the
  301.   internet protocol also deals with any fragmentation or reassembly of
  302.   the TCP segments which might be required to achieve transport and
  303.   delivery through multiple networks and interconnecting gateways.  The
  304.   internet protocol also carries information on the precedence, security
  305.   classification and compartmentation of the TCP segments, so this
  306.   information can be communicated end-to-end across multiple networks.
  307.  
  308.                            Protocol Layering
  309.  
  310.                         +---------------------+
  311.                         |     higher-level    |
  312.                         +---------------------+
  313.                         |        TCP          |
  314.                         +---------------------+
  315.                         |  internet protocol  |
  316.                         +---------------------+
  317.                         |communication network|
  318.                         +---------------------+
  319.  
  320.                                 Figure 1
  321.  
  322.   Much of this document is written in the context of TCP implementations
  323.   which are co-resident with higher level protocols in the host
  324.   computer.  As a practical matter, many computer systems will be
  325.   connected to networks via front-end computers which house the TCP and
  326.   internet protocol layers, as well as network specific software.  The
  327.   TCP specification describes an interface to the higher level protocols
  328.   which appears to be implementable even for the front-end case, as long
  329.   as a suitable host-to-front end protocol is implemented.
  330.  
  331. 1.2.  Scope
  332.  
  333.   The TCP is intended to provide a reliable process-to-process
  334.   communication service in a multinetwork environment.  The TCP is
  335.   intended to be a host-to-host protocol in common use in multiple
  336.   networks.
  337.  
  338. 1.3.  About this Document
  339.  
  340.   This document represents a specification of the behavior required of
  341.   any TCP implementation, both in its interactions with higher level
  342.   protocols and in its interactions with other TCPs.  The rest of this
  343.   section offers a very brief view of the protocol interfaces and
  344.  
  345.  
  346. [Page 2]                                                                
  347.  
  348.  
  349. December 1979                                                           
  350.                                            Transmission Control Protocol
  351.                                                             Introduction
  352.  
  353.  
  354.  
  355.   operation.  Section 2 summarizes the philosophical basis for the TCP
  356.   design.  Section 3 offers both a detailed description of the actions
  357.   required of TCP when various events occur (arrival of new segments,
  358.   user calls, errors, etc.) and the details of the formats of TCP
  359.   segments.
  360.  
  361. 1.4.  Interfaces
  362.  
  363.   The TCP interfaces on one side to user or application processes and on
  364.   the other side to a lower level protocol such as Internet Protocol.
  365.  
  366.   The interface between an application process and the TCP is
  367.   illustrated in reasonable detail.  This interface consists of a set of
  368.   calls much like the calls an operating system provides to an
  369.   application process for manipulating files.  For example, there are
  370.   calls to open and close connections and to send and receive letters on
  371.   established connections.  It is also expected that the TCP can
  372.   asynchronously communicate with application programs.  Although
  373.   considerable freedom is permitted to TCP implementors to design
  374.   interfaces which are appropriate to a particular operating system
  375.   environment, this TCP specification requires a certain minimum
  376.   functionality to be achieved at the TCP/user interface for any valid
  377.   implementation.
  378.  
  379.   The interface between TCP and lower level protocol is essentially
  380.   unspecified except that it is assume there is a mechanism whereby the
  381.   two can asynchronously pass information to each other.  Typically, one
  382.   expects the lower level protocol to specify this interface.  TCP is
  383.   designed to work in a very general environment of interconnected
  384.   networks.  Therefore, the lower level protocol which is assumed
  385.   throughout this document is the Internet Protocol.
  386.  
  387. 1.5.  Operation
  388.  
  389.   As noted above, the primary purpose of the TCP is to provide reliable,
  390.   securable logical circuit or connection service between pairs of
  391.   processes.  To provide this service on top of a less reliable internet
  392.   communication system requires facilities in the following areas:
  393.  
  394.     Basic Data Transfer
  395.     Reliability
  396.     Flow Control
  397.     Multiplexing
  398.     Connections
  399.     Precedence and Security
  400.  
  401.   The basic operation of the TCP in each of these areas is described in
  402.   the following paragraphs.
  403.  
  404.  
  405.                                                                 [Page 3]
  406.  
  407.  
  408.                                                            December 1979
  409. Transmission Control Protocol
  410. Introduction
  411.  
  412.  
  413.  
  414.   Basic Data Transfer:
  415.  
  416.     The TCP is able to transfer a continuous stream of octets in each
  417.     direction between its users by packaging some number of octets into
  418.     segments for transmission through the internet system.  In this
  419.     stream mode, the TCPs decide when to block and forward data at their
  420.     own convenience.
  421.  
  422.     For users who desire a record-oriented service, the TCP also permits
  423.     the user to submit records, called letters, for transmission.  When
  424.     the sending user indicates a record boundary (end-of-letter), this
  425.     causes the TCPs to promptly forward and deliver data up to that
  426.     point to the receiver.
  427.  
  428.   Reliability:
  429.  
  430.     The TCP must recover from data that is damaged, lost, duplicated, or
  431.     delivered out of order by the internet communication system.  This
  432.     is achieved by assigning a sequence number to each octet
  433.     transmitted, and requiring a positive acknowledgment (ACK) from the
  434.     receiving TCP.  If the ACK is not received within a timeout
  435.     interval, the data is retransmitted.  At the receiver, the sequence
  436.     numbers are used to correctly order segments that may be received
  437.     out of order and to eliminate duplicates.  Damage is handled by
  438.     adding a checksum to each segment transmitted, checking it at the
  439.     receiver, and discarding damaged segments.
  440.  
  441.     As long as the TCPs continue to function properly and the internet
  442.     system does not become completely partitioned, no transmission
  443.     errors will affect the users.  All errors in the internet
  444.     communication system are recovered by the TCP.
  445.  
  446.   Flow Control:
  447.  
  448.     TCP provides a means for the receiver to govern the amount of data
  449.     sent by the sender.  This is achieved by returning a "window" with
  450.     every ACK indicating a range of acceptable sequence numbers beyond
  451.     the last segment successfully received.  For stream mode, the window
  452.     indicates an allowed number of octets that the sender may transmit
  453.     before receiving further permission.  It is also possible for the
  454.     TCP to operate in a mode where buffer sizes and letter boundaries
  455.     are incorporated in flow control.
  456.  
  457.   Multiplexing:
  458.  
  459.     To allow for many processes within a single Host to use TCP
  460.     communication facilities simultaneously, the TCP provides a set of
  461.     addresses or ports within each host.  Concatenated with the network
  462.  
  463.  
  464. [Page 4]                                                                
  465.  
  466.  
  467. December 1979                                                           
  468.                                            Transmission Control Protocol
  469.                                                             Introduction
  470.  
  471.  
  472.  
  473.     and host addresses from the internet communication layer, this forms
  474.     a socket.  A pair of sockets uniquely identifies each connection.
  475.     That is, different connections may have a common socket on one side,
  476.     but the sockets on the other sides must be different.
  477.  
  478.     The binding of ports to processes is handled independently by each
  479.     Host.  However, it proves useful to attach frequently used processes
  480.     (e.g., a "logger" or timesharing service) to fixed sockets which are
  481.     made known to the public.  These services can then be accessed
  482.     through the known addresses.  Establishing and learning the port
  483.     addresses of other processes may involve more dynamic mechanisms.
  484.  
  485.   Connections:
  486.  
  487.     The reliability and flow control mechanisms described above require
  488.     that TCPs initialize and maintain certain status information for
  489.     each data stream.  The combination of this information, including
  490.     sockets, sequence numbers, and window sizes, is called a connection.
  491.     Each connection is uniquely specified by a pair of sockets
  492.     identifying its two sides.
  493.  
  494.     When two processes wish to communicate, their TCP's must first
  495.     establish a connection (initialize the status information on each
  496.     side).  When their communication is complete, the connection is
  497.     terminated or closed to free the resources for other uses.
  498.  
  499.     Since connections must be established over the unreliable internet
  500.     communication system, a handshake mechanism with clock-based
  501.     sequence numbers is used to avoid erroneous initialization of
  502.     connections.
  503.  
  504.   Precedence and Security:
  505.  
  506.     The users of TCP may indicate the security and precedence of their
  507.     communication.  Provision is made for default values to be used when
  508.     these features are not needed.
  509.  
  510.     
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.                                                                 [Page 5]
  524.  
  525.  
  526.                                                            December 1979
  527. Transmission Control Protocol
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582. [Page 6]                                                                
  583.  
  584.  
  585. December 1979                                                           
  586.                                            Transmission Control Protocol
  587.  
  588.  
  589.  
  590.                              2.  PHILOSOPHY
  591.  
  592. 2.1.  Elements of the Internetwork System
  593.  
  594.   The internetwork environment consists of hosts connected to networks
  595.   which are in turn interconnected via gateways.  It is assumed here
  596.   that the networks may be either local networks (e.g., the ETHERNET) or
  597.   large networks (e.g., the ARPANET), but in any case are based on
  598.   packet switching technology.  The active agents that produce and
  599.   consume messages are processes.  Various levels of protocols in the
  600.   networks, the gateways, and the hosts support an interprocess
  601.   communication system that provides two-way data flow on logical
  602.   connections between process ports.
  603.  
  604.   We specifically assume that data is transmitted from host to host
  605.   through means of a set of  networks.  When we say network, we have in
  606.   mind a packet switched network (PSN).  This assumption is probably
  607.   unnecessary, since a circuit switched network or a hybrid combination
  608.   of the two could also be used; but for concreteness, we explicitly
  609.   assume that the hosts are connected to one or more packet switches of
  610.   a PSN.
  611.  
  612.   The term packet is used generically here to mean the data of one
  613.   transaction between a host and a packet switch.  The format of data
  614.   blocks exchanged between the packet switches in a network will
  615.   generally not be of concern to us.
  616.  
  617.   Hosts are computers attached to a network, and from the communication
  618.   network's point of view, are the sources and destinations of packets.
  619.   Processes are viewed as the active elements in host computers (in
  620.   accordance with the fairly common definition of a process as a program
  621.   in execution).  Even terminals and files or other I/O devices are
  622.   viewed as communicating with each other through the use of processes.
  623.   Thus, all communication is viewed as inter-process communication.
  624.  
  625.   Since a process may need to distinguish among several communication
  626.   streams between itself and another process (or processes), we imagine
  627.   that each process may have a number of ports through which it
  628.   communicates with the ports of other processes.
  629.  
  630. 2.2.  Model of Operation
  631.  
  632.   Processes transmit data by calling on the TCP and passing buffers of
  633.   data as arguments.  The TCP packages the data from these buffers into
  634.   segments and calls on the internet module to transmit each segment to
  635.   the destination TCP.  The receiving TCP places the data from a segment
  636.   into the receiving users buffer and notifies the receiving user.  The
  637.   TCPs include control information in the segments which they use to
  638.   ensure reliable ordered data transmission.
  639.  
  640.  
  641.                                                                 [Page 7]
  642.  
  643.  
  644.                                                            December 1979
  645. Transmission Control Protocol
  646. Philosophy
  647.  
  648.  
  649.  
  650.   The model of internet communication is that there is a basic gateway
  651.   (or internet protocol module) associated with each TCP which provides
  652.   an interface to the local network.  This basic gateway packages TCP
  653.   segments inside internet datagrams and routes these datagrams to a
  654.   destination or intermediate gateway.  To transmit the datagram through
  655.   the local network, it is embedded in a local network packet.
  656.  
  657.   The packet switches may perform further packaging, fragmentation, or
  658.   other operations to achieve the delivery of the local packet to the
  659.   destination gateway.
  660.  
  661.   At a gateway between networks, the internet datagram is "unwrapped"
  662.   from its local packet and examined to determine through which network
  663.   the internet datagram should travel next.  The internet datagram is
  664.   then "wrapped" in a local packet suitable to the next network and
  665.   routed to the next gateway.
  666.  
  667.   A gateway is permitted to break up an internet datagram into smaller
  668.   internet datagram fragments if this is necessary for transmission
  669.   through the next network.  To do this, the gateway produces a set of
  670.   internet datagrams; each carrying a fragment.  Fragments may be broken
  671.   into smaller ones at intermediate gateways.  The internet datagram
  672.   fragment format is designed so that the destination gateway can
  673.   reassemble fragments into internet datagrams.
  674.  
  675.   A destination gateway unwraps the segment from the datagram (after
  676.   reassembling the datagram, if necessary) and passes it to the
  677.   destination TCP.
  678.  
  679.   This simple model of the operation glosses over many details.  One
  680.   important feature is the type of service.  This provides information
  681.   to the gateway to guide it in selecting the service parameters to be
  682.   used in traversing the next network.  Included in the type of service
  683.   information is the precedence of the datagram.  Datagrams may also
  684.   carry security information to permit host and gateways that operate in
  685.   multilevel secure environments to properly segregate datagrams for
  686.   security considerations.
  687.  
  688. 2.3.  The Host Environment
  689.  
  690.   The TCP is assumed to be a module in a time sharing operating system.
  691.   The users access the TCP much like they would access the file system.
  692.   The TCP may call on other operating system functions, for example, to
  693.   manage data structures.  The actual interface to the network is
  694.   assumed to be controlled by a device driver module.  The TCP does not
  695.   call on the network device driver directly, but rather calls on the
  696.   internet datagram protocol module which may in turn call on the device
  697.   driver.
  698.  
  699.  
  700. [Page 8]                                                                
  701.  
  702.  
  703. December 1979                                                           
  704.                                            Transmission Control Protocol
  705.                                                               Philosophy
  706.  
  707.  
  708.  
  709.   Though it is assumed here that processes are supported by the host
  710.   operating system, the mechanisms of TCP do not preclude implementation
  711.   of the TCP in a front-end processor.  However, in such an
  712.   implementation, a host-to-front-end protocol must provide the
  713.   functionality to support the type of TCP-user interface described
  714.   above.
  715.  
  716. 2.4.  Interfaces
  717.  
  718.   The TCP/user interface provides for calls made by the user on the TCP
  719.   to OPEN or CLOSE a connection, to SEND or RECEIVE data, or to obtain
  720.   STATUS about a connection.  These calls are like other calls from user
  721.   programs on the operating system, for example, the calls to open, read
  722.   from, and close a file.
  723.  
  724.   The TCP/internet interface provides calls to send and receive
  725.   datagrams addressed to TCP modules in hosts anywhere in the internet
  726.   system.  These calls have parameters for passing the address type of
  727.   service, precedence, security, and other control information.
  728.  
  729. 2.5.  Relation to Other Protocols
  730.  
  731.   The following diagram illustrates the place of the TCP in the protocol
  732.   hierarchy:
  733.  
  734.                                     
  735.        +------+ +-----+ +-----+       +-----+                    
  736.        |Telnet| | FTP | |Voice|  ...  |     |  Application Level 
  737.        +------+ +-----+ +-----+       +-----+                    
  738.              |   |         |             |                       
  739.             +-----+     +-----+       +-----+                    
  740.             | TCP |     | RTP |  ...  |     |  Host Level        
  741.             +-----+     +-----+       +-----+                    
  742.                |           |             |                       
  743.             +-------------------------------+                    
  744.             |      Internet Protocol        |  Gateway Level     
  745.             +-------------------------------+                    
  746.                            |                                     
  747.               +---------------------------+                      
  748.               |   Local Network Protocol  |    Network Level     
  749.               +---------------------------+                      
  750.                            |                                     
  751.  
  752.  
  753.  
  754.                          Protocol Relationships
  755.  
  756.                                Figure 2.
  757.  
  758.  
  759.                                                                 [Page 9]
  760.  
  761.  
  762.                                                            December 1979
  763. Transmission Control Protocol
  764. Philosophy
  765.  
  766.  
  767.  
  768.   It is expected that the TCP will be able to support higher level
  769.   protocols efficiently.  It should be easy to interface higher level
  770.   protocols like the ARPANET Telnet or AUTODIN II THP to the TCP.
  771.  
  772. 2.6.  Reliable Communication
  773.  
  774.   A stream of data sent on a TCP connection is delivered reliably and in
  775.   order at the destination.
  776.  
  777.   Transmission is made reliable via the use of sequence numbers and
  778.   acknowledgments.  Conceptually, each octet of data is assigned a
  779.   sequence number.  The sequence number of the first octet of data in a
  780.   segment is the sequence number transmitted with that segment and is
  781.   called the segment sequence number.  Segments also carry an
  782.   acknowledgment number which is the sequence number of the next
  783.   expected data octet of transmissions in the reverse direction.  When
  784.   the TCP transmits a segment, it puts a copy on a retransmission queue
  785.   and starts a timer; when the acknowledgment for that data is received,
  786.   the segment is deleted from the queue.  If the acknowledgment is not
  787.   received before the timer runs out, the segment is retransmitted.
  788.  
  789.   An acknowledgment by TCP does not guarantee that the data has been
  790.   delivered to the end user, but only that the TCP has taken the
  791.   responsibility to do so.
  792.  
  793.   To govern the flow of data into a TCP, a flow control mechanism is
  794.   employed.  The the data receiving TCP reports a window to the sending
  795.   TCP.  This window is the number of octets starting with the
  796.   acknowledgment number that the data receiving TCP is currently
  797.   prepared to receive.
  798.  
  799. 2.7.  Connection Establishment and Clearing
  800.  
  801.   To identify the separate data streams that a TCP may handle, the TCP
  802.   provides a port identifier.  Since port identifiers are selected
  803.   independently by each operating system, TCP, or user, they might not
  804.   be unique.  To provide for unique addresses at each TCP, we
  805.   concatenate an internet address identifying the TCP with a port
  806.   identifier to create a socket which will be unique throughout all
  807.   networks connected together.
  808.  
  809.   A connection is fully specified by the pair of sockets at the ends,
  810.   since the same local socket may participate in many connections to
  811.   different foreign sockets.  A connection can be used to carry data in
  812.   both directions, that is, it is "full duplex".
  813.  
  814.   TCPs are free to associate ports with processes however they choose.
  815.   However, several basic concepts seem necessary in any implementation.
  816.  
  817.  
  818. [Page 10]                                                               
  819.  
  820.  
  821. December 1979                                                           
  822.                                            Transmission Control Protocol
  823.                                                               Philosophy
  824.  
  825.  
  826.  
  827.   There must be well-known sockets which the TCP associates only with
  828.   the "appropriate" processes by some means.  We envision that processes
  829.   may "own" ports, and that processes can only initiate connections on
  830.   the ports they own.  (Means for implementing ownership is a local
  831.   issue, but we envision a Request Port user command, or a method of
  832.   uniquely allocating a group of ports to a given process, e.g., by
  833.   associating the high order bits of a port name with a given process.)
  834.  
  835.   A connection is specified in the OPEN call by the local port and
  836.   foreign socket arguments.  In return, the TCP supplies a (short) local
  837.   connection name by which the user refers to the connection in
  838.   subsequent calls.  There are several things that must be remembered
  839.   about a connection.  To store this information we imagine that there
  840.   is a data structure called a Transmission Control Block (TCB).  One
  841.   implementation strategy would have the local connection name be a
  842.   pointer to the TCB for this connection.  The OPEN call also specifies
  843.   whether the connection establishment is to be actively pursued, or to
  844.   be passively waited for.
  845.  
  846.   A foreign socket of all zeros is called unspecified.  The purpose
  847.   behind unspecified sockets is to provide a sort of "general delivery"
  848.   facility (useful for processes offering services).  This is allowed
  849.   only for passive OPENs.
  850.  
  851.   A service process that wished to provide services for unknown other
  852.   processes could issue a passive OPEN request with an unspecified
  853.   foreign socket.  Then a connection could be made with any process that
  854.   requested a connection to this local socket.  It would help if this
  855.   local socket were known to be associated with this service.
  856.  
  857.   Well-known sockets are a convenient mechanism for a priori associating
  858.   a socket address with a standard service.  For instance, the
  859.   "Telnet-Server" process might be permanently assigned to a particular
  860.   socket, and other sockets might be reserved for File Transfer, Remote
  861.   Job Entry, Text Generator, Echoer, and Sink processes (the last three
  862.   being for test purposes).  A socket address might be reserved for
  863.   access to a "Look-Up" service which would return the specific socket
  864.   at which a newly created service would be provided.  The concept of a
  865.   well-known socket is part of the TCP specification, but the assignment
  866.   of sockets to services is outside this specification.
  867.  
  868.   Processes can issue passive OPENs and wait for matching calls from
  869.   other processes and be informed by the TCP when connections have been
  870.   established.  Two processes which issue calls to each other at the
  871.   same time are correctly connected.  This flexibility is critical for
  872.   the support of distributed computing in which components act
  873.   asynchronously with respect to each other.
  874.  
  875.  
  876.  
  877.                                                                [Page 11]
  878.  
  879.  
  880.                                                            December 1979
  881. Transmission Control Protocol
  882. Philosophy
  883.  
  884.  
  885.  
  886.   There are two cases for matching the sockets in the local request and
  887.   an incoming segment.  In the first case, the local request has fully
  888.   specified the foreign socket.  In this case, the match must be exact.
  889.   In the second case, the local request has left the foreign socket
  890.   unspecified.  In this case, any foreign socket is acceptable as long
  891.   as the local sockets match.
  892.  
  893.   If there are several pending passive OPENs (recorded in TCBs) with the
  894.   same local socket, an incoming segment should be matched to a request
  895.   with the specific foreign socket in the segment, if such a request
  896.   exists, before selecting a request with an unspecified foreign socket.
  897.  
  898.   The procedures to establish and clear connections utilize synchronize
  899.   (SYN) and finis (FIN) control flags and involve an exchange of three
  900.   messages.  This exchange has been termed a three-way hand shake [3].
  901.  
  902.   A connection is initiated by the rendezvous of an arriving segment
  903.   containing a SYN and a waiting TCB entry created by a user OPEN
  904.   command.  The matching of local and foreign sockets determines when a
  905.   connection has been initiated.  The connection becomes "established"
  906.   when sequence numbers have been synchronized in both directions.
  907.  
  908.   The clearing of a connection also involves the exchange of segments,
  909.   in this case carrying the FIN control flag.
  910.  
  911. 2.8.  Data Communication
  912.  
  913.   The data that flows on a connection may be thought of as a stream of
  914.   octets, or as a sequence of records.  In TCP the records are called
  915.   letters and are of variable length.  The sending user indicates in
  916.   each SEND call whether the data in that call completes a letter by the
  917.   setting of the end-of-letter parameter.
  918.  
  919.   The length of a letter may be such that it must be broken into
  920.   segments before it can be transmitted to its destination.  We assume
  921.   that the segments will normally be reassembled into a letter before
  922.   being passed to the receiving process.  A segment may contain all or a
  923.   part of a letter, but a segment never contains parts of more than one
  924.   letter.  The end of a letter is marked by the appearance of an EOL
  925.   control flag in a segment.  A sending TCP is allowed to collect data
  926.   from the sending user and to send that data in segments at its own
  927.   convenience, until the end of letter is signaled then it must send all
  928.   unsent data.  When a receiving TCP has a complete letter, it must not
  929.   wait for more data from the sending TCP before passing the letter to
  930.   the receiving process.
  931.  
  932.   There is a coupling between letters as sent and the use of buffers of
  933.   data that cross the TCP/user interface.  Each time an end-of-letter
  934.  
  935.  
  936. [Page 12]                                                               
  937.  
  938.  
  939. December 1979                                                           
  940.                                            Transmission Control Protocol
  941.                                                               Philosophy
  942.  
  943.  
  944.  
  945.   (EOL) flag is associated with data placed into the receiving user's
  946.   buffer, the buffer is returned to the user for processing even if the
  947.   buffer is not filled.  If a letter is longer than the user's buffer,
  948.   the letter is passed to the user in buffer size units, the last of
  949.   which may be only partly full.
  950.  
  951.   The TCP is responsible for regulating the flow of segments on the
  952.   connections, as a way of preventing itself from becoming saturated or
  953.   overloaded with traffic.  This is done using a window flow control
  954.   mechanism.  The data receiving TCP reports to the data sending TCP a
  955.   window which is the range of sequence numbers of data octets that data
  956.   receiving TCP is currently prepared to accept.
  957.  
  958.   TCP also provides a means to communicate to the receiver of data that
  959.   at some point further along in the data stream than the receiver is
  960.   currently reading there is urgent data.  TCP does not attempt to
  961.   define what the user specifically does upon being notified of pending
  962.   urgent data, but the general notion is that the receiving process
  963.   should take action to read through the end urgent data quickly.
  964.  
  965. 2.9.  Precedence and Security
  966.  
  967.   The TCP makes use of the internet protocol type of service field and
  968.   security option to provide precedence and security on a per connection
  969.   basis to TCP users.  Not all TCP modules will necessarily function in
  970.   a multilevel secure environment, some may be limited to unclassified
  971.   use only, and others may operate at only one security level and
  972.   compartment.  Consequently, some TCP implementations and services to
  973.   users may be limited to a subset of the multilevel secure case.
  974.  
  975.   TCP modules which operate in a multilevel secure environment should
  976.   properly mark outgoing segments with the security, compartment, and
  977.   precedence.  Such TCP modules should also provide to their users or
  978.   higher level protocols such as Telnet or THP an interface to allow
  979.   them to specify the desired security level, compartment, and
  980.   precedence of connections.
  981.  
  982. 2.10.  Robustness Principle
  983.  
  984.   TCP implementations should follow a general principle of robustness:
  985.   be conservative in what you do, be liberal in what you accept from
  986.   others.
  987.  
  988.   
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.                                                                [Page 13]
  996.  
  997.  
  998.                                                            December 1979
  999. Transmission Control Protocol
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054. [Page 14]                                                               
  1055.  
  1056.  
  1057. December 1979                                                           
  1058.                                            Transmission Control Protocol
  1059.  
  1060.  
  1061.  
  1062.                       3.  FUNCTIONAL SPECIFICATION
  1063.  
  1064. 3.1.  Header Format
  1065.  
  1066.   TCP segments are sent as internet datagrams.  The Internet Protocol
  1067.   header carries several information fields, including the source and
  1068.   destination host addresses [1].  A TCP header follows the internet
  1069.   header, supplying information specific to the TCP protocol.  This
  1070.   division allows for the existence of host level protocols other than
  1071.   TCP.
  1072.  
  1073.   TCP Header Format
  1074.  
  1075.                                     
  1076.     0                   1                   2                   3   
  1077.     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
  1078.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1079.    |          Source Port          |       Destination Port        |
  1080.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1081.    |                        Sequence Number                        |
  1082.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1083.    |                    Acknowledgment Number                      |
  1084.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1085.    |  Data |           |U|A|E|R|S|F|                               |
  1086.    | Offset| Reserved  |R|C|O|S|Y|I|            Window             |
  1087.    |       |           |G|K|L|T|N|N|                               |
  1088.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1089.    |           Checksum            |         Urgent Pointer        |
  1090.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1091.    |                    Options                    |    Padding    |
  1092.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1093.    |                             data                              |
  1094.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1095.  
  1096.                             TCP Header Format
  1097.  
  1098.           Note that one tick mark represents one bit position.
  1099.  
  1100.                                Figure 3.
  1101.  
  1102.   Source Port:  16 bits
  1103.  
  1104.     The source port number.
  1105.  
  1106.   Destination Port:  16 bits
  1107.  
  1108.     The destination port number.
  1109.  
  1110.  
  1111.  
  1112.  
  1113.                                                                [Page 15]
  1114.  
  1115.  
  1116.                                                            December 1979
  1117. Transmission Control Protocol
  1118. Functional Specification
  1119.  
  1120.  
  1121.  
  1122.   Sequence Number:  32 bits
  1123.  
  1124.     The sequence number of the first data octet in this segment.
  1125.  
  1126.   Acknowledgment Number:  32 bits
  1127.  
  1128.     If the ACK control bit is set this field contains the value of the
  1129.     next sequence number the sender of the segment is expecting to
  1130.     receive.
  1131.  
  1132.   Data Offset:  4 bits
  1133.  
  1134.     The number of 32 bit words in the TCP Header.  This indicates where
  1135.     the data begins.  The TCP header including options is an integral
  1136.     number of 32 bits long.
  1137.  
  1138.   Reserved:  6 bits
  1139.  
  1140.     Reserved for future use.  Must be zero.
  1141.  
  1142.   Control Bits:  8 bits (from left to right):
  1143.  
  1144.     URG:  Urgent Pointer field significant
  1145.     ACK:  Acknowledgment field significant
  1146.     EOL:  End of Letter
  1147.     RST:  Reset the connection
  1148.     SYN:  Synchronize sequence numbers
  1149.     FIN:  No more data from sender
  1150.  
  1151.   Window:  16 bits
  1152.  
  1153.     The number of data octets beginning with the one indicated in the
  1154.     acknowledgment field which the sender of this segment is willing to
  1155.     accept.
  1156.  
  1157.   Checksum:  16 bits
  1158.  
  1159.     The checksum field is the 16 bit one's complement of the one's
  1160.     complement sum of all 16 bit words in the header and text.  If a
  1161.     segment contains an odd number of header and text octets to be
  1162.     checksummed, the last octet is padded on the right with zeros to
  1163.     form a 16 bit word for checksum purposes.  The pad is not
  1164.     transmitted as part of the segment.  While computing the checksum,
  1165.     the checksum field itself is replaced with zeros.
  1166.  
  1167.     The checksum also covers a 96 bit pseudo header conceptually
  1168.     prefixed to the TCP header.  This pseudo header contains the Source
  1169.     Address, the Destination Address, the Protocol, and TCP length.
  1170.  
  1171.  
  1172. [Page 16]                                                               
  1173.  
  1174.  
  1175. December 1979                                                           
  1176.                                            Transmission Control Protocol
  1177.                                                 Functional Specification
  1178.  
  1179.  
  1180.  
  1181.     This gives the TCP protection against misrouted segments.  This
  1182.     information is carried in the Internet Protocol and is transferred
  1183.     across the TCP/Network interface in the arguments or results of
  1184.     calls by the TCP on the IP.
  1185.  
  1186.                      +--------------------------+
  1187.                      |      Source Address      |
  1188.                      +--------------------------+
  1189.                      |    Destination Address   |
  1190.                      +--------------------------+
  1191.                      | zero | PTCL | TCP Length |
  1192.                      +--------------------------+
  1193.  
  1194.       The TCP Length is the TCP header plus the data length in octets
  1195.       (this is not a explicitly transmitted quantity, but is computed
  1196.       from the total length, and the header length).
  1197.  
  1198.   Urgent Pointer:  16 bits
  1199.  
  1200.     This field communicates the current value of the urgent pointer as a
  1201.     positive offset from the sequence number in this segment.  The
  1202.     urgent pointer points to the sequence number of the octet following
  1203.     the urgent data.  This field should only be interpreted in segments
  1204.     with the URG control bit set.
  1205.  
  1206.   Options:  variable
  1207.  
  1208.     Options may occupy space at the end of the TCP header and are a
  1209.     multiple of 8 bits in length.  All options are included in the
  1210.     checksum.  An option may begin on any octet boundary.  There are two
  1211.     cases for the format of an option:
  1212.  
  1213.       Case 1:  A single octet of option-kind.
  1214.  
  1215.       Case 2:  An octet of option-kind, an octet of option-length, and
  1216.                the actual option-data octets.
  1217.  
  1218.     The option-length counts the two octets of option-kind and
  1219.     option-length as well as the option-data octets.
  1220.  
  1221.     Note that the list of options may be shorter than the data offset
  1222.     field might imply.  The content of the header beyond the
  1223.     End-of-Option option should be header padding (i.e., zero).
  1224.  
  1225.     A TCP must implement all options.
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.                                                                [Page 17]
  1232.  
  1233.  
  1234.                                                            December 1979
  1235. Transmission Control Protocol
  1236. Functional Specification
  1237.  
  1238.  
  1239.  
  1240.     Currently defined options include (kind indicated in octal):
  1241.  
  1242.       Kind     Length    Meaning
  1243.       ----     ------    -------
  1244.        0         -       End of option list.
  1245.        1         -       No-Operation.
  1246.       100        -       Reserved.
  1247.       105        4       Buffer Size.
  1248.       
  1249.  
  1250.     Specific Option Definitions
  1251.  
  1252.       End of Option List
  1253.  
  1254.         +--------+
  1255.         |00000000|
  1256.         +--------+
  1257.          Kind=0
  1258.  
  1259.         This option code indicates the end of the option list.  This
  1260.         might not coincide with the end of the TCP header according to
  1261.         the Data Offset field.  This is used at the end of all options,
  1262.         not the end of each option, and need only be used if the end of
  1263.         the options would not otherwise coincide with the end of the TCP
  1264.         header.
  1265.  
  1266.       No-Operation
  1267.  
  1268.         +--------+
  1269.         |00000001|
  1270.         +--------+
  1271.          Kind=1
  1272.  
  1273.         This option code may be used between options, for example, to
  1274.         align the beginning of a subsequent option on a word boundary.
  1275.         There is no guarantee that senders will use this option, so
  1276.         receivers must be prepared to process options even if they do
  1277.         not begin on a word boundary.
  1278.  
  1279.       Buffer Size
  1280.  
  1281.         +--------+--------+---------+--------+
  1282.         |01000101|00000100|    buffer size   |
  1283.         +--------+--------+---------+--------+
  1284.          Kind=105 Length=4
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290. [Page 18]                                                               
  1291.  
  1292.  
  1293. December 1979                                                           
  1294.                                            Transmission Control Protocol
  1295.                                                 Functional Specification
  1296.  
  1297.  
  1298.  
  1299.         Buffer Size Option Data:  16 bits
  1300.  
  1301.           If this option is present, then it communicates the receive
  1302.           buffer size at the TCP which sends this segment.  This field
  1303.           should only be sent in segments with the SYN control bit set.
  1304.           If this option is not used, the default buffer size of one
  1305.           octet is assumed.
  1306.  
  1307.   Padding:  variable
  1308.  
  1309.     The TCP header padding is used to ensure that the TCP header ends
  1310.     and data begins on a 32 bit boundary.  The padding is composed of
  1311.     zeros.
  1312.  
  1313. 3.2.  Terminology
  1314.  
  1315.   Before we can discuss very much about the operation of the TCP we need
  1316.   to introduce some detailed terminology.  The maintenance of a TCP
  1317.   connection requires the remembering of several variables.  We conceive
  1318.   of these variables being stored in a connection record called a
  1319.   Transmission Control Block or TCB.  Among the variables stored in the
  1320.   TCB are the local and remote socket numbers, the security and
  1321.   precedence of the connection, pointers to the user's send and receive
  1322.   buffers, pointers to the retransmit queue and to the current segment.
  1323.   In addition several variables relating to the send and receive
  1324.   sequence numbers are stored in the TCB.
  1325.  
  1326.     Send Sequence Variables
  1327.  
  1328.       SND.UNA - send unacknowledged
  1329.       SND.NXT - send sequence
  1330.       SND.WND - send window
  1331.       SND.BS  - send buffer size
  1332.       SND.UP  - send urgent pointer
  1333.       SND.WL  - send sequence number used for last window update
  1334.       SND.LBB - send last buffer beginning
  1335.       ISS     - initial send sequence number
  1336.  
  1337.     Receive Sequence Variables
  1338.  
  1339.       RCV.NXT - receive sequence
  1340.       RCV.WND - receive window
  1341.       RCV.BS  - receive buffer size
  1342.       RCV.UP  - receive urgent pointer
  1343.       RCV.LBB - receive last buffer beginning
  1344.       IRS     - initial receive sequence number
  1345.  
  1346.  
  1347.  
  1348.  
  1349.                                                                [Page 19]
  1350.  
  1351.  
  1352.                                                            December 1979
  1353. Transmission Control Protocol
  1354. Functional Specification
  1355.  
  1356.  
  1357.  
  1358.   The following diagrams may help to relate some of these variables to
  1359.   the sequence space.
  1360.  
  1361.   Send Sequence Space
  1362.  
  1363.                    1         2          3          4      
  1364.               ----------|----------|----------|---------- 
  1365.                      SND.UNA    SND.NXT    SND.UNA        
  1366.                                           +SND.WND        
  1367.  
  1368.         1 - old sequence numbers which have been acknowledged  
  1369.         2 - sequence numbers of unacknowledged data            
  1370.         3 - sequence numbers allowed for new data transmission 
  1371.         4 - future sequence numbers which are not yet allowed  
  1372.  
  1373.                           Send Sequence Space
  1374.  
  1375.                                Figure 4.
  1376.     
  1377.     
  1378.  
  1379.   Receive Sequence Space
  1380.  
  1381.                        1          2          3      
  1382.                    ----------|----------|---------- 
  1383.                           RCV.NXT    RCV.NXT        
  1384.                                     +RCV.WND        
  1385.  
  1386.         1 - old sequence numbers which have been acknowledged  
  1387.         2 - sequence numbers allowed for new reception         
  1388.         3 - future sequence numbers which are not yet allowed  
  1389.  
  1390.                          Receive Sequence Space
  1391.  
  1392.                                Figure 5.
  1393.     
  1394.     
  1395.  
  1396.   There are also some variables used frequently in the discussion that
  1397.   take their values from the fields of the current segment.
  1398.  
  1399.  
  1400.  
  1401.  
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408. [Page 20]                                                               
  1409.  
  1410.  
  1411. December 1979                                                           
  1412.                                            Transmission Control Protocol
  1413.                                                 Functional Specification
  1414.  
  1415.  
  1416.  
  1417.     Current Segment Variables
  1418.  
  1419.       SEG.SEQ - segment sequence number
  1420.       SEG.ACK - segment acknowledgment number
  1421.       SEG.LEN - segment length
  1422.       SEG.WND - segment window
  1423.       SEG.UP  - segment urgent pointer
  1424.       SEG.PRC - segment precedence value
  1425.  
  1426.   A connection progresses through a series of states during its
  1427.   lifetime.  The states are:  LISTEN, SYN-SENT, SYN-RECEIVED,
  1428.   ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, TIME-WAIT, CLOSE-WAIT, CLOSING,
  1429.   and the fictional state CLOSED.  Closed is fictional because it
  1430.   represents the state when there is no TCB, and therefore, no
  1431.   connection.  Briefly the meanings of the states are:
  1432.  
  1433.     LISTEN - represents waiting for a connection request from any remote
  1434.     TCP and port.
  1435.  
  1436.     SYN-SENT - represents waiting for a matching connection request
  1437.     after having sent a connection request.
  1438.  
  1439.     SYN-RECEIVED - represents waiting for a confirming connection
  1440.     request acknowledgment after having both sent and received a
  1441.     connection request.
  1442.  
  1443.     ESTABLISHED - represents an open connection, ready to transmit and
  1444.     receive data segments.
  1445.  
  1446.     FIN-WAIT-1 - represents waiting for a connection termination request
  1447.     from the remote TCP, or an acknowledgment of the connection
  1448.     termination request previously sent.
  1449.  
  1450.     FIN-WAIT-2 - represents waiting for a connection termination request
  1451.     from the remote TCP.
  1452.  
  1453.     TIME-WAIT - represents waiting for enough time to pass to be sure
  1454.     the remote TCP received the acknowledgment of its connection
  1455.     termination request.
  1456.  
  1457.     CLOSE-WAIT - represents waiting for a connection termination request
  1458.     from the local user.
  1459.  
  1460.     CLOSING - represents waiting for a connection termination request
  1461.     acknowledgment from the remote TCP.
  1462.  
  1463.     CLOSED - represents no connection state at all.
  1464.  
  1465.  
  1466.  
  1467.                                                                [Page 21]
  1468.  
  1469.  
  1470.                                                            December 1979
  1471. Transmission Control Protocol
  1472. Functional Specification
  1473.  
  1474.  
  1475.  
  1476.   A TCP connection progresses from one state to another in response to
  1477.   events.  The events are the user calls, OPEN, SEND, RECEIVE, CLOSE,
  1478.   ABORT, and STATUS; the incoming segments, particularly those
  1479.   containing the SYN and FIN flags; and timeouts.
  1480.  
  1481.   The Glossary contains a more complete list of terms and their
  1482.   definitions.
  1483.  
  1484.   The state diagram in figure 6 only illustrates state changes, together
  1485.   with the causing events and resulting actions, but addresses neither
  1486.   error conditions nor actions which are not connected with state
  1487.   changes.  In a later section, more detail is offered with respect to
  1488.   the reaction of the TCP to events.
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526. [Page 22]                                                               
  1527.  
  1528.  
  1529. December 1979                                                           
  1530.                                            Transmission Control Protocol
  1531.                                                 Functional Specification
  1532.  
  1533.  
  1534.  
  1535.                                     
  1536.                               +---------+ ---------\      active OPEN  
  1537.                               |  CLOSED |            \    -----------  
  1538.                               +---------+<---------\   \   create TCB  
  1539.                                 |     ^              \   \  snd SYN    
  1540.                    passive OPEN |     |   CLOSE        \   \           
  1541.                    ------------ |     | ----------       \   \         
  1542.                     create TCB  |     | delete TCB         \   \       
  1543.                                 V     |                      \   \     
  1544.                               +---------+            CLOSE    |    \   
  1545.                               |  LISTEN |          ---------- |     |  
  1546.                               +---------+          delete TCB |     |  
  1547.                    rcv SYN      |     |     SEND              |     |  
  1548.                   -----------   |     |    -------            |     V  
  1549.  +---------+      snd SYN,ACK  /       \   snd SYN          +---------+
  1550.  |         |<-----------------           ------------------>|         |
  1551.  |   SYN   |                    rcv SYN                     |   SYN   |
  1552.  |   RCVD  |<-----------------------------------------------|   SENT  |
  1553.  |         |                    snd ACK                     |         |
  1554.  |         |------------------           -------------------|         |
  1555.  +---------+   rcv ACK of SYN  \       /  rcv SYN,ACK       +---------+
  1556.    |           --------------   |     |   -----------                  
  1557.    |                  x         |     |     snd ACK                    
  1558.    |                            V     V                                
  1559.    |  CLOSE                   +---------+                              
  1560.    | -------                  |  ESTAB  |                              
  1561.    | snd FIN                  +---------+                              
  1562.    |                   CLOSE    |     |    rcv FIN                     
  1563.    V                  -------   |     |    -------                     
  1564.  +---------+          snd FIN  /       \   snd ACK          +---------+
  1565.  |  FIN    |<-----------------           ------------------>|  CLOSE  |
  1566.  | WAIT-1  |------------------           -------------------|   WAIT  |
  1567.  +---------+          rcv FIN  \       /   CLOSE            +---------+
  1568.    | rcv ACK of FIN   -------   |     |   -------                      
  1569.    | --------------   snd ACK   |     |   snd FIN                      
  1570.    V        x                   V     V                                
  1571.  +---------+                  +---------+                              
  1572.  |FINWAIT-2|                  | CLOSING |                              
  1573.  +---------+                  +---------+                              
  1574.    | rcv FIN                          | rcv ACK of FIN                 
  1575.    | -------    Timeout=2MSL          | --------------                 
  1576.    V snd ACK    ------------          V   delete TCB                   
  1577.  +---------+     delete TCB   +---------+                              
  1578.  |TIME WAIT|----------------->| CLOSED  |                              
  1579.  +---------+                  +---------+                              
  1580.  
  1581.                       TCP Connection State Diagram
  1582.                                Figure 6.
  1583.  
  1584.  
  1585.                                                                [Page 23]
  1586.  
  1587.  
  1588.                                                            December 1979
  1589. Transmission Control Protocol
  1590. Functional Specification
  1591.  
  1592.  
  1593.  
  1594. 3.3.  Sequence Numbers
  1595.  
  1596.   A fundamental notion in the design is that every octet of data sent
  1597.   over a TCP connection has a sequence number.  Since every octet is
  1598.   sequenced, each of them can be acknowledged.  The acknowledgment
  1599.   mechanism employed is cumulative so that an acknowledgment of sequence
  1600.   number X indicates that all octets up to but not including X have been
  1601.   received.  This mechanism allows for straight-forward duplicate
  1602.   detection in the presence of retransmission.
  1603.  
  1604.   It is essential to remember that the actual sequence number space is
  1605.   finite, though very large.  This space ranges from 0 to 2**32 - 1.
  1606.   Since the space is finite, all arithmetic dealing with sequence
  1607.   numbers must be performed modulo 2**32.  This unsigned arithmetic
  1608.   preserves the relationship of sequence numbers as they cycle from
  1609.   2**32 - 1 to 0 again.  There are some subtleties to computer modulo
  1610.   arithmetic, so great care should be taken in programming the
  1611.   comparison of such values.  The typical kinds of sequence number
  1612.   comparisons which the TCP must perform include:
  1613.  
  1614.     (a)  Determining that an acknowledgment refers to some sequence
  1615.          number sent but not yet acknowledged.
  1616.  
  1617.     (b)  Determining that all sequence numbers occupied by a segment
  1618.          have been acknowledged (e.g., to remove the segment from a
  1619.          retransmission queue).
  1620.  
  1621.     (c)  Determining that an incoming segment contains sequence numbers
  1622.          which are expected (i.e., that the segment "overlaps" the
  1623.          receive window).
  1624.  
  1625.   On send connections the following comparisons are needed:
  1626.  
  1627.     older sequence numbers                        newer sequence numbers
  1628.  
  1629.                                     
  1630.         SND.UNA                SEG.ACK                 SND.NXT  
  1631.            |                      |                       |     
  1632.        ----|----XXXXXXX------XXXXXXXXXX---------XXXXXX----|---- 
  1633.            |    |            |    |             |         |     
  1634.                 |            |                  |               
  1635.              Segment 1    Segment 2          Segment 3          
  1636.  
  1637.                       <----- sequence space ----->
  1638.  
  1639.                    Sending Sequence Space Information
  1640.  
  1641.                                Figure 7.
  1642.  
  1643.  
  1644. [Page 24]                                                               
  1645.  
  1646.  
  1647. December 1979                                                           
  1648.                                            Transmission Control Protocol
  1649.                                                 Functional Specification
  1650.  
  1651.  
  1652.  
  1653.     SND.UNA = oldest unacknowledged sequence number
  1654.  
  1655.     SND.NXT = next sequence number to be sent
  1656.  
  1657.     SEG.ACK = acknowledgment (next sequence number expected by the
  1658.               acknowledging TCP)
  1659.  
  1660.     SEG.SEQ = first sequence number of a segment
  1661.  
  1662.     SEG.SEQ+SEG.LEN-1 = last sequence number of a segment
  1663.  
  1664.   An acceptable acknowledgment, SEG.ACK, is one for which the inequality
  1665.   below holds:
  1666.  
  1667.     0 < (SEG.ACK - SND.UNA) =< (SND.NXT - SND.UNA)
  1668.  
  1669.   or:
  1670.  
  1671.     SND.UNA < SEG.ACK =< SND.NXT
  1672.  
  1673.   Note that all arithmetic is modulo 2**32 and that comparisons are
  1674.   unsigned.  "=<" means "less than or equal".
  1675.  
  1676.   Similarly, the determination that a particular segment has been fully
  1677.   acknowledged can be made if the inequality below holds:
  1678.  
  1679.     0 < (SEG.SEQ+SEG.LEN-1 - SND.UNA) < (SEG.ACK - SND.UNA)
  1680.  
  1681.   SEG.LEN is the number of octets occupied by the data in the segment.
  1682.   It is important to note that SEG.LEN must be non-zero; segments which
  1683.   do not occupy any sequence space (e.g., empty acknowledgment segments)
  1684.   are never placed on the retransmission queue, so would not go through
  1685.   this particular test.
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.                                                                [Page 25]
  1704.  
  1705.  
  1706.                                                            December 1979
  1707. Transmission Control Protocol
  1708. Functional Specification
  1709.  
  1710.  
  1711.  
  1712.   On receive connections the following comparisons are needed:
  1713.  
  1714.     older sequence numbers                        newer sequence numbers
  1715.  
  1716.                                     
  1717.                 RCV.NXT                         RCV.NXT+RCV.WND 
  1718.                    |                               |            
  1719.        ---------XXX|XXX------XXXXXXXXXX---------XXX|XX--------- 
  1720.                 |  |         |                  |  |            
  1721.                 |            |                  |               
  1722.              Segment 1    Segment 2          Segment 3          
  1723.  
  1724.                       <----- sequence space ----->
  1725.  
  1726.                   Receiving Sequence Space Information
  1727.  
  1728.                                 Figure 8.
  1729.  
  1730.     RCV.NXT = next sequence number expected on incoming segments
  1731.  
  1732.     RCV.NXT+RCV.WND = last sequence number expected on incoming
  1733.         segments, plus one
  1734.  
  1735.     SEG.SEQ = first sequence number occupied by the incoming segment
  1736.  
  1737.     SEG.SEQ+SEG.LEN-1 = last sequence number occupied by the incoming
  1738.         segment
  1739.  
  1740.   A segment is judged to occupy a portion of valid receive sequence
  1741.   space if
  1742.  
  1743.      0 =< (SEG.SEQ+SEG.LEN-1 - RCV.NXT) < (RCV.NXT+RCV.WND - RCV.NXT)
  1744.  
  1745.   SEG.SEQ+SEG.LEN-1 is the last sequence number occupied by the segment;
  1746.   RCV.NXT is the next sequence number expected on an incoming segment;
  1747.   and RCV.NXT+RCV.WND is the right edge of the receive window.
  1748.  
  1749.   Actually, it is a little more complicated than this.  Due to zero
  1750.   windows and zero length segments, we have four cases for the
  1751.   acceptability of an incoming segment:
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762. [Page 26]                                                               
  1763.  
  1764.  
  1765. December 1979                                                           
  1766.                                            Transmission Control Protocol
  1767.                                                 Functional Specification
  1768.  
  1769.  
  1770.  
  1771.     Segment Receive  Test
  1772.     Length  Window
  1773.     ------- -------  -------------------------------------------
  1774.  
  1775.        0       0     SEG.SEQ = RCV.NXT
  1776.  
  1777.        0      >0     RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND
  1778.  
  1779.       >0       0     not acceptable
  1780.  
  1781.       >0      >0     RCV.NXT < SEG.SEQ+SEG.LEN =< RCV.NXT+RCV.WND
  1782.  
  1783.   Note that the acceptance test for a segment, since it requires the end
  1784.   of a segment to lie in the window, is somewhat more restrictive than
  1785.   is absolutely necessary.  If at least the first sequence number of the
  1786.   segment lies in the receive window, or if some part of the segment
  1787.   lies in the receive window, then the segment might be judged
  1788.   acceptable.  Thus, in figure 8, at least segments 1 and 2 are
  1789.   acceptable by the strict rule, and segment 3 may or may not be,
  1790.   depending on the strictness of interpretation of the rule.
  1791.  
  1792.   Note that when the receive window is zero no segments should be
  1793.   acceptable except ACK segments.  Thus, it should be possible for a TCP
  1794.   to maintain a zero receive window while transmitting data and
  1795.   receiving ACKs.
  1796.  
  1797.   We have taken advantage of the numbering scheme to protect certain
  1798.   control information as well.  This is achieved by implicitly including
  1799.   some control flags in the sequence space so they can be retransmitted
  1800.   and acknowledged without confusion (i.e., one and only one copy of the
  1801.   control will be acted upon).  Control information is not physically
  1802.   carried in the segment data space.  Consequently, we must adopt rules
  1803.   for implicitly assigning sequence numbers to control.  The SYN and FIN
  1804.   are the only controls requiring this protection, and these controls
  1805.   are used only at connection opening and closing.  For sequence number
  1806.   purposes, the SYN is considered to occur before the first actual data
  1807.   octet of the segment in which it occurs, while the FIN is considered
  1808.   to occur after the last actual data octet in a segment in which it
  1809.   occurs.  The segment length includes both data and sequence space
  1810.   occupying controls.
  1811.  
  1812.   Initial Sequence Number Selection
  1813.  
  1814.   The protocol places no restriction on a particular connection being
  1815.   used over and over again.  A connection is defined by a pair of
  1816.   sockets.  New instances of a connection will be referred to as
  1817.   incarnations of the connection.  The problem that arises owing to this
  1818.   is -- "how does the TCP identify duplicate segments from previous
  1819.  
  1820.  
  1821.                                                                [Page 27]
  1822.  
  1823.  
  1824.                                                            December 1979
  1825. Transmission Control Protocol
  1826. Functional Specification
  1827.  
  1828.  
  1829.  
  1830.   incarnations of the connection?"  This problem becomes apparent if the
  1831.   connection is being opened and closed in quick succession, or if the
  1832.   connection breaks with loss of memory and is then reestablished.
  1833.  
  1834.   To avoid confusion we must prevent segments from being emitted with
  1835.   sequence numbers which duplicate those which are still in the network.
  1836.   We want to assure this, even if a TCP crashes and loses all knowledge
  1837.   of the sequence numbers it has been using.  When new connections are
  1838.   created, an initial sequence number (ISN) generator is employed which
  1839.   selects a new 32 bit ISN.  The generator is bound to a (possibly
  1840.   fictitious) 32 bit clock whose low order bit is incremented roughly
  1841.   every 4 microseconds.  Thus, the ISN cycles approximately every 4.55
  1842.   hours.  Since we assume that segments will stay in the network no more
  1843.   than tens of seconds or minutes, at worst, we can reasonably assume
  1844.   that ISN's will be unique.
  1845.  
  1846.   For each connection there is a send sequence number and a receive
  1847.   sequence number.  The initial send sequence number (ISS) is chosen by
  1848.   the data sending TCP, and the initial receive sequence number (IRS) is
  1849.   learned during the connection establishing procedure.
  1850.  
  1851.   For a connection to be established or initialized, the two TCPs must
  1852.   synchronize on each other's initial sequence numbers.  This is done in
  1853.   an exchange of connection establishing messages carrying a control bit
  1854.   called "SYN" (for synchronize) and the initial sequence numbers.  As a
  1855.   shorthand, messages carrying the SYN bit are also called "SYNs".
  1856.   Hence, the solution requires a suitable mechanism for picking an
  1857.   initial sequence number and a slightly involved handshake to exchange
  1858.   the ISN's.  A "three way handshake" is necessary because sequence
  1859.   numbers are not tied to a global clock in the network, and TCPs may
  1860.   have different mechanisms for picking the ISN's.  The receiver of the
  1861.   first SYN has no way of knowing whether the segment was an old delayed
  1862.   one or not, unless it remembers the last sequence number used on the
  1863.   connection (which is not always possible), and so it must ask the
  1864.   sender to verify this SYN.
  1865.  
  1866.   The "three way handshake" and the advantages of a "clock-driven"
  1867.   scheme are discussed in [3].
  1868.  
  1869.   Knowing When to Keep Quiet
  1870.  
  1871.   To be sure that a TCP does not create a segment that carries a
  1872.   sequence number which may be duplicated by an old segment remaining in
  1873.   the network, the TCP must keep quiet for a maximum segment lifetime
  1874.   (MSL) before assigning any sequence numbers upon starting up or
  1875.   recovering from a crash in which memory of sequence numbers in use was
  1876.   lost.  For this specification the MSL is taken to be 2 minutes.  This
  1877.   is an engineering choice, and may be changed if experience indicates
  1878.  
  1879.  
  1880. [Page 28]                                                               
  1881.  
  1882.  
  1883. December 1979                                                           
  1884.                                            Transmission Control Protocol
  1885.                                                 Functional Specification
  1886.  
  1887.  
  1888.  
  1889.   it is desirable to do so.  Note that if a TCP is reinitialized in some
  1890.   sense, yet retains its memory of sequence numbers in use, then it need
  1891.   not wait at all; it must only be sure to use sequence numbers larger
  1892.   than those recently used.
  1893.  
  1894.   It should be noted that this strategy does not protect against
  1895.   spoofing or other replay type duplicate message problems.
  1896.  
  1897. 3.4.  Establishing a connection
  1898.  
  1899.   The "three-way handshake" is essentially a unidirectional attempt to
  1900.   establish a connection, i.e., there is an initiator and a responder.
  1901.   The TCP can also establish a connection when a simultaneous initiation
  1902.   occurs.  A simultaneous attempt occurs when one TCP receives a "SYN"
  1903.   segment which carries no acknowledgment after it has sent a "SYN".  Of
  1904.   course, the arrival of an old duplicate "SYN" segment can potentially
  1905.   make it appear, to the recipient, that a simultaneous connection
  1906.   initiation is in progress.  Proper use of "reset" segments can
  1907.   disambiguate these cases.  Several examples of connection initiation
  1908.   are offered below.  Although these examples do not show connection
  1909.   synchronization using data-carrying segments, this is perfectly
  1910.   legitimate, so long as the receiving TCP doesn't deliver the data to
  1911.   the user until it is clear the data is valid (i.e., the data must be
  1912.   buffered at the receiver until the connection reaches the ESTABLISHED
  1913.   state).  The three-way handshake reduces the possibility of false
  1914.   connections.  It is the implementation of a trade-off between memory
  1915.   and messages to provide information for this checking.
  1916.  
  1917.   The simplest three-way handshake is shown in figure 9 below.  The
  1918.   figures should be interpreted in the following way.  Each line is
  1919.   numbered for reference purposes.  Right arrows (-->) indicate
  1920.   departure of a TCP segment from TCP A to TCP B, or arrival of a
  1921.   segment at B from A.  Left arrows (<--), indicate the reverse.
  1922.   Ellipsis (...) indicates a segment which is still in the network
  1923.   (delayed).  An "XXX" indicates a segment which is lost or rejected.
  1924.   Comments appear in parentheses.  TCP states represent the state AFTER
  1925.   the departure or arrival of the segment (whose contents are shown in
  1926.   the center of each line).  Segment contents are shown in abbreviated
  1927.   form, with sequence number, control flags, and ACK field.  Other
  1928.   fields such as window, addresses, lengths, and text have been left out
  1929.   in the interest of clarity.
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.                                                                [Page 29]
  1940.  
  1941.  
  1942.                                                            December 1979
  1943. Transmission Control Protocol
  1944. Functional Specification
  1945.  
  1946.  
  1947.  
  1948.   
  1949.  
  1950.       TCP A                                                TCP B
  1951.  
  1952.   1.  CLOSED                                               LISTEN
  1953.  
  1954.   2.  SYN-SENT    --> <SEQ=100><CTL=SYN>               --> SYN-RECEIVED
  1955.  
  1956.   3.  ESTABLISHED <-- <SEQ=300><ACK=101><CTL=SYN,ACK>  <-- SYN-RECEIVED
  1957.  
  1958.   4.  ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK>       --> ESTABLISHED
  1959.  
  1960.   5.  ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK><DATA> --> ESTABLISHED
  1961.  
  1962.           Basic 3-Way Handshake for Connection Synchronization
  1963.  
  1964.                                 Figure 9.
  1965.  
  1966.   In line 2 of figure 9, TCP A begins by sending a SYN segment
  1967.   indicating that it will use sequence numbers starting with sequence
  1968.   number 100.  In line 3, TCP B sends a SYN and acknowledges the SYN it
  1969.   received from TCP A.  Note that the acknowledgment field indicates TCP
  1970.   B is now expecting to hear sequence 101, acknowledging the SYN which
  1971.   occupied sequence 100.
  1972.  
  1973.   At line 4, TCP A responds with an empty segment containing an ACK for
  1974.   TCP B's SYN; and in line 5, TCP A sends some data.  Note that the
  1975.   sequence number of the segment in line 5 is the same as in line 4
  1976.   because the ACK does not occupy sequence number space (if it did, we
  1977.   would wind up ACKing ACK's!).
  1978.  
  1979.   Simultaneous initiation is only slightly more complex, as is shown in
  1980.   figure 10.  Each TCP cycles from CLOSED to SYN-SENT to SYN-RECEIVED to
  1981.   ESTABLISHED.
  1982.  
  1983.   The principle reason for the three-way handshake is to prevent old
  1984.   duplicate connection initiations from causing confusion.  To deal with
  1985.   this, a special control message, reset, has been devised.  A TCP which
  1986.   receives a reset message first verifies that the ACK field of the
  1987.   reset acknowledges something the TCP sent (otherwise, the message is
  1988.   ignored).  If the receiving TCP is in a  non-synchronized state (i.e.,
  1989.   SYN-SENT, SYN-RECEIVED), it returns to LISTEN on receiving an
  1990.   acceptable reset.  If the TCP is in one of the synchronized states
  1991.   (ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, TIME-WAIT, CLOSE-WAIT, CLOSING),
  1992.   it aborts the connection and informs its user.  We discuss this latter
  1993.   case under "half-open" connections below.
  1994.  
  1995.  
  1996.  
  1997.  
  1998. [Page 30]                                                               
  1999.  
  2000.  
  2001. December 1979                                                           
  2002.                                            Transmission Control Protocol
  2003.                                                 Functional Specification
  2004.  
  2005.  
  2006.  
  2007.   
  2008.  
  2009.       TCP A                                        TCP B
  2010.  
  2011.   1.  CLOSED                                       CLOSED
  2012.  
  2013.   2.  SYN-SENT     --> <SEQ=100><CTL=SYN>          ...
  2014.  
  2015.   3.  SYN-RECEIVED <-- <SEQ=300><CTL=SYN>          <-- SYN-SENT
  2016.  
  2017.   4.               ... <SEQ=100><CTL=SYN>          --> SYN-RECEIVED
  2018.  
  2019.   5.  SYN-RECEIVED --> <SEQ=101><ACK=301><CTL=ACK> ...
  2020.  
  2021.   6.  ESTABLISHED  <-- <SEQ=301><ACK=101><CTL=ACK> <-- SYN-RECEIVED
  2022.  
  2023.   7.               ... <SEQ=101><ACK=301><CTL=ACK> --> ESTABLISHED
  2024.  
  2025.                 Simultaneous Connection Synchronization
  2026.  
  2027.                                Figure 10.
  2028.  
  2029.   
  2030.  
  2031.       TCP A                                                TCP B
  2032.  
  2033.   1.  CLOSED                                               LISTEN
  2034.  
  2035.   2.  SYN-SENT    --> <SEQ=100><CTL=SYN>               ...
  2036.  
  2037.   3.  (duplicate) ... <SEQ=1000><CTL=SYN>              --> SYN-RECEIVED
  2038.  
  2039.   4.  SYN-SENT    <-- <SEQ=300><ACK=1001><CTL=SYN,ACK> <-- SYN-RECEIVED
  2040.  
  2041.   5.  SYN-SENT    --> <SEQ=1001><CTL=RST>              --> LISTEN
  2042.                                                            (ACK is ok)
  2043.  
  2044.   6.              ... <SEQ=100><CTL=SYN>               --> SYN-RECEIVED
  2045.  
  2046.   7.  SYN-SENT    <-- <SEQ=400><ACK=101><CTL=SYN,ACK>  <-- SYN-RECEIVED
  2047.  
  2048.   8.  ESTABLISHED --> <SEQ=101><ACK=401><CTL=ACK>      --> ESTABLISHED
  2049.  
  2050.                     Recovery from Old Duplicate SYN
  2051.  
  2052.                                Figure 11.
  2053.  
  2054.   As a simple example of recovery from old duplicates, consider
  2055.  
  2056.  
  2057.                                                                [Page 31]
  2058.  
  2059.  
  2060.                                                            December 1979
  2061. Transmission Control Protocol
  2062. Functional Specification
  2063.  
  2064.  
  2065.  
  2066.   figure 11.  At line 3, an old duplicate SYN arrives at TCP B.  TCP B
  2067.   cannot tell that this is an old duplicate, so it responds normally
  2068.   (line 4).  TCP A detects that the ACK field is incorrect and returns a
  2069.   RST (reset) with its SEQ field selected to make the segment
  2070.   believable.  TCP B, on receiving the RST, returns to the LISTEN state.
  2071.   When the original SYN (pun intended) finally arrives at line 6, the
  2072.   synchronization proceeds normally.  If the SYN at line 6 had arrived
  2073.   before the RST, a more complex exchange might have occurred with RST's
  2074.   sent in both directions.
  2075.  
  2076.   Half-Open Connections and Other Anomalies
  2077.  
  2078.   An established connection is said to be  "half-open" if one of the
  2079.   TCPs has closed or aborted the connection at its end without the
  2080.   knowledge of the other, or if the two ends of the connection have
  2081.   become desynchronized owing to a crash that resulted in loss of
  2082.   memory.  Such connections will automatically become reset if an
  2083.   attempt is made to send data in either direction.  However, half-open
  2084.   connections are expected to be unusual, and the recovery procedure is
  2085.   mildly involved.
  2086.  
  2087.   If at site A the connection no longer exists, then an attempt by the
  2088.   user at site B to send any data on it will result in the site B TCP
  2089.   receiving a reset control message.  Such a message should indicate to
  2090.   the site B TCP that something is wrong, and it is expected to abort
  2091.   the connection.
  2092.  
  2093.   Assume that two user processes A and B are communicating with one
  2094.   another when a crash occurs causing loss of memory to A's TCP.
  2095.   Depending on the operating system supporting A's TCP, it is likely
  2096.   that some error recovery mechanism exists.  When the TCP is up again,
  2097.   A is likely to start again from the beginning or from a recovery
  2098.   point.  As a result, A will probably try to OPEN the connection again
  2099.   or try to SEND on the connection it believes open.  In the latter
  2100.   case, it receives the error message "connection not open" from the
  2101.   local (A's) TCP.  In an attempt to establish the connection, A's TCP
  2102.   will send a segment containing SYN.  This scenario leads to the
  2103.   example shown in figure 12.  After TCP A crashes, the user attempts to
  2104.   re-open the connection.  TCP B, in the meantime, thinks the connection
  2105.   is open.
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. [Page 32]                                                               
  2117.  
  2118.  
  2119. December 1979                                                           
  2120.                                            Transmission Control Protocol
  2121.                                                 Functional Specification
  2122.  
  2123.  
  2124.  
  2125.   
  2126.  
  2127.       TCP A                                           TCP B
  2128.  
  2129.   1.  (CRASH)                               (send 300,receive 100)
  2130.  
  2131.   2.  CLOSED                                           ESTABLISHED
  2132.  
  2133.   3.  SYN-SENT --> <SEQ=400><CTL=SYN>              --> (??)
  2134.  
  2135.   4.  (!!)     <-- <SEQ=300><ACK=100><CTL=ACK>     <-- ESTABLISHED
  2136.  
  2137.   5.  SYN-SENT --> <SEQ=100><CTL=RST>              --> (Abort!!)
  2138.  
  2139.   6.                                                   CLOSED
  2140.  
  2141.   7.  SYN-SENT --> <SEQ=400><CTL=SYN>              --> CLOSED
  2142.  
  2143.   8.  (Abort!!)<-- <SEQ=xxx><ACK=401><CTL=RST,ACK> <-- CLOSED
  2144.  
  2145.   9.  CLOSED                                           CLOSED
  2146.  
  2147.                      Half-Open Connection Discovery
  2148.  
  2149.                                Figure 12.
  2150.  
  2151.   When the SYN arrives at line 3, TCP B, being in a synchronized state,
  2152.   responds with an acknowledgment indicating what sequence it next
  2153.   expects to hear (ACK 100).  TCP A sees that this segment does not
  2154.   acknowledge anything it sent and, being unsynchronized, sends a reset
  2155.   (RST) because it has detected a half-open connection.  TCP B aborts at
  2156.   line 5.  TCP A will continue to retransmit its SYN; and if the user at
  2157.   TCP B re-opens the connection, eventually everything will work out.
  2158.   In the figure TCP B does not reopen the connection, and in line 8
  2159.   sends a reset to reject the offered connection.
  2160.  
  2161.   An interesting alternative case occurs when TCP A crashes and TCP B
  2162.   tries to send data on what it thinks is a synchronized connection.
  2163.   This is illustrated in figure 13.  In this case, the data arriving at
  2164.   TCP A from TCP B (line 2) is unacceptable because no such connection
  2165.   exists, so TCP A sends a RST.  The RST is acceptable so TCP B
  2166.   processes it and aborts the connection.
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.                                                                [Page 33]
  2176.  
  2177.  
  2178.                                                            December 1979
  2179. Transmission Control Protocol
  2180. Functional Specification
  2181.  
  2182.  
  2183.  
  2184.   
  2185.  
  2186.         TCP A                                              TCP B
  2187.  
  2188.   1.  (CRASH)                                   (send 300,receive 100)
  2189.  
  2190.   2.  (??)    <-- <SEQ=300><ACK=100><DATA=10><CTL=ACK> <-- ESTABLISHED
  2191.  
  2192.   3.          --> <SEQ=100><CTL=RST>                   --> (ABORT!!)
  2193.  
  2194.            Active Side Causes Half-Open Connection Discovery
  2195.  
  2196.                                Figure 13.
  2197.  
  2198.   In figure 14, we find the two TCPs A and B with passive connections
  2199.   waiting for SYN.  An old duplicate arriving at TCP B (line 2) stirs B
  2200.   into action.  A SYN-ACK is returned (line 3) and causes TCP A to
  2201.   generate a RST (the ACK in line 3 is not acceptable).  TCP B accepts
  2202.   the reset and returns to its passive LISTEN state.
  2203.  
  2204.   
  2205.  
  2206.       TCP A                                         TCP B
  2207.  
  2208.   1.  LISTEN                                        LISTEN
  2209.  
  2210.   2.       ... <SEQ=Z><CTL=SYN>                -->  SYN-RECEIVED
  2211.  
  2212.   3.  (??) <-- <SEQ=X><ACK=Z+1><CTL=SYN,ACK>   <--  SYN-RECEIVED
  2213.  
  2214.   4.       --> <SEQ=Z+1><CTL=RST>              -->  (return to LISTEN!)
  2215.  
  2216.   5.  LISTEN                                        LISTEN
  2217.  
  2218.        Old Duplicate SYN Initiates a Reset on two Passive Sockets
  2219.  
  2220.                                Figure 14.
  2221.  
  2222.   A variety of other cases are possible, all of which are accounted for
  2223.   by the following rules for RST generation and processing.
  2224.  
  2225.   Reset Generation
  2226.  
  2227.   As a general rule, reset (RST) should be sent whenever a segment
  2228.   arrives which apparently is not intended for the current or a future
  2229.   incarnation of the connection.  A reset should not be sent if it is
  2230.   not clear that this is the case.  Thus, if any segment arrives for a
  2231.   nonexistent connection, a reset should be sent.  If a segment ACKs
  2232.  
  2233.  
  2234. [Page 34]                                                               
  2235.  
  2236.  
  2237. December 1979                                                           
  2238.                                            Transmission Control Protocol
  2239.                                                 Functional Specification
  2240.  
  2241.  
  2242.  
  2243.   something which has never been sent on the current connection, then
  2244.   one of the following two cases applies.
  2245.  
  2246.   1.  If the connection is in any non-synchronized state (LISTEN,
  2247.   SYN-SENT, SYN-RECEIVED) or if the connection does not exist, a reset
  2248.   (RST) should be formed and sent for any segment that acknowledges
  2249.   something not yet sent.  The RST should take its SEQ field from the
  2250.   ACK field of the offending segment (if the ACK control bit was set),
  2251.   and its ACK bit should be reset (zero), except to refuse a initial
  2252.   SYN.  A reset is also sent if an incoming segment has a security level
  2253.   or compartment which does not exactly match the level and compartment
  2254.   requested for the connection.  If the precedence of the incoming
  2255.   segment is less than the precedence level requested a reset is sent.
  2256.  
  2257.   2.  If the connection is in a synchronized state (ESTABLISHED,
  2258.   FIN-WAIT-1, FIN-WAIT-2, TIME-WAIT, CLOSE-WAIT, CLOSING), any
  2259.   unacceptable segment should elicit only an empty acknowledgment
  2260.   segment containing the current send-sequence number and an
  2261.   acknowledgment indicating the next sequence number expected to be
  2262.   received.
  2263.  
  2264.   Reset Processing
  2265.  
  2266.   All reset (RST) segments are validated by checking their SEQ-fields.
  2267.   A reset is valid if its sequence number is the next expected sequence
  2268.   number.  In the case of a RST received in response to an initial SYN
  2269.   any sequence number is acceptable if the ACK field acknowledges the
  2270.   SYN.
  2271.  
  2272.   The receiver of a RST first validates it, then changes state.  If the
  2273.   receiver was in the LISTEN state, it ignores it.  If the receiver was
  2274.   in SYN-RECEIVED state and had previously been in the LISTEN state,
  2275.   then the receiver returns to the LISTEN state, otherwise the receiver
  2276.   aborts the connection and goes to the CLOSED state.  If the receiver
  2277.   was in any other state, it aborts the connection and advises the user
  2278.   and goes to the CLOSED state.
  2279.  
  2280. 3.5.  Closing a Connection
  2281.  
  2282.   CLOSE is an operation meaning "I have no more data to send."  The
  2283.   notion of closing a full-duplex connection is subject to ambiguous
  2284.   interpretation, of course, since it may not be obvious how to treat
  2285.   the receiving side of the connection.  We have chosen to treat CLOSE
  2286.   in a simplex fashion.  The user who CLOSEs may continue to RECEIVE
  2287.   until he is told that the other side has CLOSED also.  Thus, a program
  2288.   could initiate several SENDs followed by a CLOSE, and then continue to
  2289.   RECEIVE until signaled that a RECEIVE failed because the other side
  2290.   has CLOSED.  We assume that the TCP will unilaterally inform a user,
  2291.  
  2292.  
  2293.                                                                [Page 35]
  2294.  
  2295.  
  2296.                                                            December 1979
  2297. Transmission Control Protocol
  2298. Functional Specification
  2299.  
  2300.  
  2301.  
  2302.   even if no RECEIVEs are outstanding, that the other side has closed,
  2303.   so the user can terminate his side gracefully.  A TCP will reliably
  2304.   deliver all buffers SENT before the connection was CLOSED so a user
  2305.   who expects no data in return need only wait to hear the connection
  2306.   was CLOSED successfully to know that all his data was received at the
  2307.   destination TCP.
  2308.  
  2309.   There are essentially three cases:
  2310.  
  2311.     1) The user initiates by telling the TCP to CLOSE the connection
  2312.  
  2313.     2) The remote TCP initiates by sending a FIN control signal
  2314.  
  2315.     3) Both users CLOSE simultaneously
  2316.  
  2317.   Case 1:  Local user initiates the close
  2318.  
  2319.     In this case, a FIN segment can be constructed and placed on the
  2320.     outgoing segment queue.  No further SENDs from the user will be
  2321.     accepted by the TCP, and it enters the FIN-WAIT-1 state.  RECEIVEs
  2322.     are allowed in this state.  All segments preceding and including FIN
  2323.     will be retransmitted until acknowledged.  When the other TCP has
  2324.     both acknowledged the FIN and sent a FIN of its own, the first TCP
  2325.     can ACK this FIN.  It should be noted that a TCP receiving a FIN
  2326.     will ACK but not send its own FIN until its user has CLOSED the
  2327.     connection also.
  2328.  
  2329.   Case 2:  TCP receives a FIN from the network
  2330.  
  2331.     If an unsolicited FIN arrives from the network, the receiving TCP
  2332.     can ACK it and tell the user that the connection is closing.  The
  2333.     user should respond with a CLOSE, upon which the TCP can send a FIN
  2334.     to the other TCP.  The TCP then waits until its own FIN is
  2335.     acknowledged whereupon it deletes the connection.  If an ACK is not
  2336.     forthcoming, after a timeout the connection is aborted and the user
  2337.     is told.
  2338.  
  2339.   Case 3:  both users close simultaneously
  2340.  
  2341.     A simultaneous CLOSE by users at both ends of a connection causes
  2342.     FIN segments to be exchanged.  When all segments preceding the FINs
  2343.     have been processed and acknowledged, each TCP can ACK the FIN it
  2344.     has received.  Both will, upon receiving these ACKs, delete the
  2345.     connection.
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352. [Page 36]                                                               
  2353.  
  2354.  
  2355. December 1979                                                           
  2356.                                            Transmission Control Protocol
  2357.                                                 Functional Specification
  2358.  
  2359.  
  2360.  
  2361.   
  2362.  
  2363.       TCP A                                                TCP B
  2364.  
  2365.   1.  ESTABLISHED                                          ESTABLISHED
  2366.  
  2367.   2.  (Close)
  2368.       FIN-WAIT-1  --> <SEQ=100><CTL=FIN>               --> CLOSE-WAIT
  2369.  
  2370.   3.  FIN-WAIT-2  <-- <SEQ=300><ACK=101><CTL=ACK>      <-- CLOSE-WAIT
  2371.  
  2372.   4.                                                       (Close)
  2373.       TIME-WAIT   <-- <SEQ=301><CTL=FIN>               <-- CLOSING
  2374.  
  2375.   5.  TIME-WAIT   --> <SEQ=100><ACK=301><CTL=ACK>      --> CLOSED
  2376.  
  2377.   6.  (2 MSL)
  2378.       CLOSED
  2379.  
  2380.                          Normal Close Sequence
  2381.  
  2382.                                Figure 15.
  2383.  
  2384.   
  2385.  
  2386.       TCP A                                                TCP B
  2387.  
  2388.   1.  ESTABLISHED                                          ESTABLISHED
  2389.  
  2390.   2.  (Close)                                              (Close)
  2391.       FIN-WAIT-1  --> <SEQ=100><CTL=FIN>               ... FIN-WAIT-1
  2392.                   <-- <SEQ=300><CTL=FIN>               <--
  2393.                   ... <SEQ=100><CTL=FIN>               -->
  2394.  
  2395.   3.  CLOSING     --> <SEQ=100><ACK=301><CTL=ACK>      ... CLOSING
  2396.                   <-- <SEQ=300><ACK=101><CTL=ACK>      <--
  2397.                   ... <SEQ=100><ACK=301><CTL=ACK>      -->
  2398.  
  2399.   4.  CLOSED                                               CLOSED
  2400.  
  2401.                       Simultaneous Close Sequence
  2402.  
  2403.                                Figure 16.
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410.  
  2411.                                                                [Page 37]
  2412.  
  2413.  
  2414.                                                            December 1979
  2415. Transmission Control Protocol
  2416. Functional Specification
  2417.  
  2418.  
  2419.  
  2420. 3.6.  Precedence and Security
  2421.  
  2422.   The intent is that connection be allowed only between ports operating
  2423.   with exactly the same security and compartment values and at the
  2424.   higher of the precedence level requested by the two parts.
  2425.  
  2426.   The precedence levels are:
  2427.  
  2428.     flash override - 111
  2429.     flash          - 110
  2430.     immediate      - 10X
  2431.     priority       - 01X
  2432.     routine        - 00X
  2433.  
  2434.   The security levels are:
  2435.  
  2436.     top secret    - 11
  2437.     secret        - 10
  2438.     confidential  - 01
  2439.     unclassified  - 00
  2440.  
  2441.   The compartments are assigned by the Defense Communications Agency.
  2442.   The defaults are precedence:  routine, security:  unclassified,
  2443.   compartment:  zero.  A host which does not implement precedence or
  2444.   security feature should clear these fields to zero for segments it
  2445.   sends.
  2446.  
  2447.   A connection attempt with mismatched security/compartment values or a
  2448.   lower precedence value should be rejected by sending a reset.
  2449.  
  2450.   Note that TCP modules which operate only at the default value of
  2451.   precedence will still have to check the precedence of incoming
  2452.   segments and possibly raise the precedence level they use on the
  2453.   connection.
  2454.  
  2455. 3.7.  Data Communication
  2456.  
  2457.   Once the connection is established data is communicated by the
  2458.   exchange of segments.  Because segments may be lost due to errors
  2459.   (checksum test failure), or network congestion, TCP uses
  2460.   retransmission (after a timeout) to ensure delivery of every segment.
  2461.   Duplicate segments may arrive due to network or TCP retransmission.
  2462.   As discussed in the section on sequence numbers the TCP performs
  2463.   certain tests on the sequence and acknowledgment numbers in the
  2464.   segments to verify their acceptability.
  2465.  
  2466.   The sender of data keeps track of the next sequence number to use in
  2467.   the variable SND.NXT.  The receiver of data keeps track of the next
  2468.  
  2469.  
  2470. [Page 38]                                                               
  2471.  
  2472.  
  2473. December 1979                                                           
  2474.                                            Transmission Control Protocol
  2475.                                                 Functional Specification
  2476.  
  2477.  
  2478.  
  2479.   sequence number to expect in the variable RCV.NXT.  The sender of data
  2480.   keeps track of the oldest unacknowledged sequence number in the
  2481.   variable SND.UNA.  If the data flow is momentarily idle and all data
  2482.   sent has been acknowledged then the three variables will be equal.
  2483.  
  2484.   When the sender creates a segment and transmits it the sender advances
  2485.   SND.NXT.  When the receiver accepts a segment it advances RCV.NXT and
  2486.   sends an acknowledgment.  When the data sender receives an
  2487.   acknowledgment it advances SND.UNA.  The extent to which the values of
  2488.   these variables differ is a measure of the delay in the communication.
  2489.  
  2490.   Normally the amount by which the variables are advanced is the length
  2491.   of the data in the segment.  However, when letters are used there are
  2492.   special provisions for coordination the sequence numbers, the letter
  2493.   boundaries, and the receive buffer boundaries.
  2494.  
  2495.   End of Letter Sequence Number Adjustments
  2496.  
  2497.   There is provision in TCP for the receiver of data to optionally
  2498.   communicate to the sender of data on a connection at the time of the
  2499.   connection synchronization the receiver's buffer size.  If this is
  2500.   done the receiver must use this fixed size of buffers for the lifetime
  2501.   of the connection.  If a buffer size is communicated then there is a
  2502.   coordination between receive buffers, letters, and sequence numbers.
  2503.  
  2504.   Each time a buffer is completed either due to being filled or due to
  2505.   an end of letter, the sequence number is incremented through the end
  2506.   of that buffer.
  2507.  
  2508.   That is, whenever an EOL is transmitted, the sender advances its send
  2509.   sequence number, SND.NXT, by an amount sufficient to consume all the
  2510.   unused space in the receiver's buffer.  The amount of space consumed
  2511.   in this fashion is subtracted from the send window just as is the
  2512.   space consumed by actual data.
  2513.  
  2514.   And, whenever an EOL is received, the receiver advances its receive
  2515.   sequence number, RCV.NXT, by an amount sufficient to consume all the
  2516.   unused space in the receiver's buffer.  The amount of space consumed
  2517.   in this fashion is subtracted from the receive window just as is the
  2518.   space consumed by actual data.
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.                                                                [Page 39]
  2530.  
  2531.  
  2532.                                                            December 1979
  2533. Transmission Control Protocol
  2534. Functional Specification
  2535.  
  2536.  
  2537.  
  2538.     older sequence numbers                        newer sequence numbers
  2539.  
  2540.             |           Buffer 1            |   Buffer 2       
  2541.             |                               |                  
  2542.         ----+-------------------------------+----------------- 
  2543.             XXXXXXXXXXXXXXXXXXXXX+++++++++++                   
  2544.             |                    |          |                  
  2545.             |<-----SEG.LEN------>|          |                  
  2546.             |                    |          |                  
  2547.             |                    |          |                  
  2548.          SEG.SEQ                 A          B                  
  2549.  
  2550.                     XXX - data octets from segment 
  2551.                     +++ - phantom data             
  2552.  
  2553.                       <----- sequence space ----->
  2554.  
  2555.                         End of Letter Adjustment
  2556.  
  2557.                                Figure 17.
  2558.  
  2559.   In the case illustrated above, if the segment does not carry an EOL
  2560.   flag, the next value of SND.NXT or RCV.NXT will be A.  If it does
  2561.   carry an EOL flag, the next value will be B.
  2562.  
  2563.   The exchange of buffer size and sequencing information is done in
  2564.   units of octets.  If no buffer size is stated, then the buffer size is
  2565.   assumed to be 1 octet.  The receiver tells the sender the size of the
  2566.   buffer in a SYN segment that contains the 16 bit buffer size data in
  2567.   an option field in the TCP header.
  2568.  
  2569.   Each EOL advances the sequence number (SN) to the next buffer boundary
  2570.  
  2571.     While LBB < SEG.SEQ+SEG.LEN
  2572.     Do LBB <- LBB + BS End
  2573.     SN <- LBB
  2574.  
  2575.     where LBB is the Last Buffer Beginning, and BS is the buffer size.
  2576.  
  2577.   The CLOSE user call implies an end of letter, as does the FIN control
  2578.   flag in an incoming segment.
  2579.  
  2580.   The Communication of Urgent Information
  2581.  
  2582.   The objective of the TCP urgent mechanism is to allow the sending user
  2583.   to stimulate the receiving user to accept some urgent data and to
  2584.   permit the receiving TCP to indicate to the receiving user when all
  2585.   the currently known urgent data has been received by the user.
  2586.  
  2587.  
  2588. [Page 40]                                                               
  2589.  
  2590.  
  2591. December 1979                                                           
  2592.                                            Transmission Control Protocol
  2593.                                                 Functional Specification
  2594.  
  2595.  
  2596.  
  2597.   This mechanism permits a point in the data stream to be designated as
  2598.   the end of "urgent" information.  Whenever this point is in advance of
  2599.   the receive sequence number (RCV.NXT) at the receiving TCP, that TCP
  2600.   should tell the user to go into "urgent mode"; when the receive
  2601.   sequence number catches up to the urgent pointer, the TCP should tell
  2602.   user to go into "normal mode".  If the urgent pointer is updated while
  2603.   the user is in "read fast" mode, the update will be invisible to the
  2604.   user.
  2605.  
  2606.   The method employs a urgent field which is carried in all segments
  2607.   transmitted.  The URG control flag indicates that the urgent field is
  2608.   meaningful and should be added to the segment sequence number to yield
  2609.   the urgent pointer.  The absence of this flag indicates that the
  2610.   urgent pointer has not changed.
  2611.  
  2612.   To send an urgent indication the user must also send at least one data
  2613.   octet.  If the sending user also indicates end of letter, timely
  2614.   delivery of the urgent information to the destination process is
  2615.   enhanced.
  2616.  
  2617.   Managing the Window
  2618.  
  2619.   The window sent in each segment indicates the range of sequence number
  2620.   the sender of the window (the data receiver) is currently prepared to
  2621.   accept.  There is an assumption that this is somehow related to to the
  2622.   currently available data buffer space available for this connection.
  2623.  
  2624.   Indicating a large window encourages transmissions.  If more data
  2625.   arrives than can be accepted, this will result in excessive
  2626.   retransmissions, adding unnecessarily to the load on the network and
  2627.   the TCPs.  Indicating a small window may restrict the transmission of
  2628.   data to the point of introducing a round trip delay between each new
  2629.   segment transmitted.
  2630.  
  2631.   The mechanisms provided allow a TCP to advertise a large window and to
  2632.   subsequently advertise a much smaller window without having accepted
  2633.   that much data.  This, so called "shrinking the window," is strongly
  2634.   discouraged.  The robustness principle dictates that TCPs will not
  2635.   shrink the window themselves, but will be prepared for such behavior
  2636.   on the part of other TCPs.
  2637.  
  2638.   The sending TCP must be prepared to accept and send at least one octet
  2639.   of new data even if the send window is zero.  The sending TCP should
  2640.   regularly retransmit to the receiving TCP even when the window is
  2641.   zero.  Two minutes is recommended for the retransmission interval when
  2642.   the window is zero.  This retransmission is essential to guarantee
  2643.   that when either TCP has a zero window the re-opening of the window
  2644.   will be reliably reported to the other.
  2645.  
  2646.  
  2647.                                                                [Page 41]
  2648.  
  2649.  
  2650.                                                            December 1979
  2651. Transmission Control Protocol
  2652. Functional Specification
  2653.  
  2654.  
  2655.  
  2656.   Users must keep reading connections they close for sending until the
  2657.   TCP says no more data.
  2658.  
  2659.   In a connection with a one-way data flow, the window information will
  2660.   be carried in acknowledgment segments that all have the same sequence
  2661.   number so there will be no way to reorder them if they arrive out of
  2662.   order.  This is not a serious problem, but it will allow the window
  2663.   information to be on occasion temporarily based on old reports from
  2664.   the data receiver.
  2665.  
  2666. 3.8.  Interfaces
  2667.  
  2668.   There are of course two interfaces of concern:  the user/TCP interface
  2669.   and the TCP/IP interface.  We have a fairly elaborate model of the
  2670.   user/TCP interface, but only a sketch of the interface to the lower
  2671.   level protocol module.
  2672.  
  2673.   User/TCP Interface
  2674.  
  2675.     The functional description of user commands to the TCP is, at best,
  2676.     fictional, since every operating system will have different
  2677.     facilities.  Consequently, we must warn readers that different TCP
  2678.     implementations may have different user interfaces.  However, all
  2679.     TCPs must provide a certain minimum set of services to guarantee
  2680.     that all TCP implementations can support the same protocol
  2681.     hierarchy.  This section specifies the functional interfaces
  2682.     required of all TCP implementations.
  2683.  
  2684.     TCP User Commands
  2685.  
  2686.       The following sections functionally characterize a USER/TCP
  2687.       interface.  The notation used is similar to most procedure or
  2688.       function calls in high level languages, but this usage is not
  2689.       meant to rule out trap type service calls (e.g., SVCs, UUOs,
  2690.       EMTs).
  2691.  
  2692.       The user commands described below specify the basic functions the
  2693.       TCP must perform to support interprocess communication.
  2694.       Individual implementations should define their own exact format,
  2695.       and may provide combinations or subsets of the basic functions in
  2696.       single calls.  In particular, some implementations may wish to
  2697.       automatically OPEN a connection on the first SEND or RECEIVE
  2698.       issued by the user for a given connection.
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706. [Page 42]                                                               
  2707.  
  2708.  
  2709. December 1979                                                           
  2710.                                            Transmission Control Protocol
  2711.                                                 Functional Specification
  2712.  
  2713.  
  2714.  
  2715.       In providing interprocess communication facilities, the TCP must
  2716.       not only accept commands, but must also return information to the
  2717.       processes it serves.  The latter consists of:
  2718.  
  2719.         (a) general information about a connection (e.g., interrupts,
  2720.         remote close, binding of unspecified foreign socket).
  2721.  
  2722.         (b) replies to specific user commands indicating success or
  2723.         various types of failure.
  2724.  
  2725.       Although the means for signaling user processes and the exact
  2726.       format of replies will vary from one implementation to another, it
  2727.       would promote common understanding and testing if a common set of
  2728.       codes were adopted.  Such a set of event codes is described below.
  2729.  
  2730.       Open
  2731.  
  2732.         Format:  OPEN (local port, foreign socket, active/passive
  2733.         [, buffer size] [, timeout] [, precedence]
  2734.         [, security/compartment]) -> local connection name
  2735.  
  2736.         We assume that the local TCP is aware of the identity of the
  2737.         processes it serves and will check the authority of the process
  2738.         to use the connection specified.  Depending upon the
  2739.         implementation of the TCP, the local network and TCP identifiers
  2740.         for the source address will either be supplied by the TCP or by
  2741.         the processes that serve it (e.g., the program which interfaces
  2742.         the TCP network).  These considerations are the result of
  2743.         concern about security, to the extent that no TCP be able to
  2744.         masquerade as another one, and so on.  Similarly, no process can
  2745.         masquerade as another without the collusion of the TCP.
  2746.  
  2747.         If the active/passive flag is set to passive, then this is a
  2748.         call to LISTEN for an incoming connection.  A passive open may
  2749.         have either a fully specified foreign socket to wait for a
  2750.         particular connection or an unspecified foreign socket to wait
  2751.         for any call.  A fully specified passive call can be made active
  2752.         by the subsequent execution of a SEND.
  2753.  
  2754.         A full-duplex transmission control block (TCB) is created and
  2755.         partially filled in with data from the OPEN command parameters.
  2756.  
  2757.         On an active OPEN command, the TCP will begin the procedure to
  2758.         synchronize (i.e., establish) the connection at once.
  2759.  
  2760.         The buffer size, if present, indicates that the caller will
  2761.         always receive data from the connection in that size of buffers.
  2762.         This buffer size is a measure of the buffer between the user and
  2763.  
  2764.  
  2765.                                                                [Page 43]
  2766.  
  2767.  
  2768.                                                            December 1979
  2769. Transmission Control Protocol
  2770. Functional Specification
  2771.  
  2772.  
  2773.  
  2774.         the local TCP.  The buffer size between the two TCPs may be
  2775.         different.
  2776.  
  2777.         The timeout, if present, permits the caller to set up a timeout
  2778.         for all buffers transmitted on the connection.  If a buffer is
  2779.         not successfully delivered to the destination within the timeout
  2780.         period, the TCP will abort the connection.  The present global
  2781.         default is 30 seconds.  The buffer retransmission rate may vary;
  2782.         most likely, it will be related to the measured time for
  2783.         responses from the remote TCP.
  2784.  
  2785.         The TCP or some component of the operating system will verify
  2786.         the users authority to open a connection with the specified
  2787.         precedence or security/compartment.  The absence of precedence
  2788.         or security/compartment specification in the OPEN call indicates
  2789.         the default values should be used.
  2790.  
  2791.         TCP will accept incoming requests as matching only if the
  2792.         security/compartment information is exactly the same and only if
  2793.         the precedence is equal to or higher than the precedence
  2794.         requested in the OPEN call.
  2795.  
  2796.         The precedence for the connection is the higher of the values
  2797.         requested in the OPEN call and received from the incoming
  2798.         request, and fixed at that value for the life of the connection.
  2799.  
  2800.         Depending on the TCP implementation, either a local connection
  2801.         name will be returned to the user by the TCP, or the user will
  2802.         specify this local connection name (in which case another
  2803.         parameter is needed in the call).  The local connection name can
  2804.         then be used as a short hand term for the connection defined by
  2805.         the <local socket, foreign socket> pair.
  2806.  
  2807.       Send
  2808.  
  2809.         Format:  SEND(local connection name, buffer address, byte count,
  2810.         EOL flag, URGENT flag [, timeout])
  2811.  
  2812.         This call causes the data contained in the indicated user buffer
  2813.         to be sent on the indicated connection.  If the connection has
  2814.         not been opened, the SEND is considered an error.  Some
  2815.         implementations may allow users to SEND first; in which case, an
  2816.         automatic OPEN would be done.  If the calling process is not
  2817.         authorized to use this connection, an error is returned.
  2818.  
  2819.         If the EOL flag is set, the data is the End Of a Letter, and the
  2820.         EOL bit will be set in the last TCP segment created from the
  2821.  
  2822.  
  2823.  
  2824. [Page 44]                                                               
  2825.  
  2826.  
  2827. December 1979                                                           
  2828.                                            Transmission Control Protocol
  2829.                                                 Functional Specification
  2830.  
  2831.  
  2832.  
  2833.         buffer.  If the EOL flag is not set, subsequent SENDs will
  2834.         appear to be part of the same letter.
  2835.  
  2836.         If the URGENT flag is set, segments resulting from this call
  2837.         will have the urgent pointer set to indicate that some of the
  2838.         data associated with this call is urgent.  This facility, for
  2839.         example, can be used to simulate "break" signals from terminals
  2840.         or error or completion codes from I/O devices.  The semantics of
  2841.         this signal to the receiving process are unspecified.  The
  2842.         receiving TCP will signal the urgent condition to the receiving
  2843.         process as long as the urgent pointer indicates that data
  2844.         preceding the urgent pointer has not been consumed by the
  2845.         receiving process.  The purpose of urgent is to stimulate the
  2846.         receiver to accept some urgent data and to indicate to the
  2847.         receiver when all the currently known urgent data has been
  2848.         received.
  2849.  
  2850.         The number of times the sending user's TCP signals urgent will
  2851.         not necessarily be equal to the number of times the receiving
  2852.         user will be notified of the presence of urgent data.
  2853.  
  2854.         If no foreign socket was specified in the OPEN, but the
  2855.         connection is established (e.g., because a LISTENing connection
  2856.         has become specific due to a foreign segment arriving for the
  2857.         local socket), then the designated buffer is sent to the implied
  2858.         foreign socket.  In general, users who make use of OPEN with an
  2859.         unspecified foreign socket can make use of SEND without ever
  2860.         explicitly knowing the foreign socket address.
  2861.  
  2862.         However, if a SEND is attempted before the foreign socket
  2863.         becomes specified, an error will be returned.  Users can use the
  2864.         STATUS call to determine the status of the connection.  In some
  2865.         implementations the TCP may notify the user when an unspecified
  2866.         socket is bound.
  2867.  
  2868.         If a timeout is specified, then the current timeout for this
  2869.         connection is changed to the new one.
  2870.  
  2871.         In the simplest implementation, SEND would not return control to
  2872.         the sending process until either the transmission was complete
  2873.         or the timeout had been exceeded.  However, this simple method
  2874.         is both highly subject to deadlocks (for example, both sides of
  2875.         the connection might try to do SENDs before doing any RECEIVEs)
  2876.         and offers poor performance, so it is not recommended.  A more
  2877.         sophisticated implementation would return immediately to allow
  2878.         the process to run concurrently with network I/O, and,
  2879.         furthermore, to allow multiple SENDs to be in progress.
  2880.  
  2881.  
  2882.  
  2883.                                                                [Page 45]
  2884.  
  2885.  
  2886.                                                            December 1979
  2887. Transmission Control Protocol
  2888. Functional Specification
  2889.  
  2890.  
  2891.  
  2892.         Multiple SENDs are served in first come, first served order, so
  2893.         the TCP will queue those it cannot service immediately.
  2894.  
  2895.         We have implicitly assumed an asynchronous user interface in
  2896.         which a SEND later elicits some kind of SIGNAL or
  2897.         pseudo-interrupt from the serving TCP.  An alternative is to
  2898.         return a response immediately.  For instance, SENDs might return
  2899.         immediate local acknowledgment, even if the segment sent had not
  2900.         been acknowledged by the distant TCP.  We could optimistically
  2901.         assume eventual success.  If we are wrong, the connection will
  2902.         close anyway due to the timeout.  In implementations of this
  2903.         kind (synchronous), there will still be some asynchronous
  2904.         signals, but these will deal with the connection itself, and not
  2905.         with specific segments or letters.
  2906.  
  2907.         NOTA BENE: In order for the process to distinguish among error
  2908.         or success indications for different SENDs, it might be
  2909.         appropriate for the buffer address to be returned along with the
  2910.         coded response to the SEND request.  We will offer an example
  2911.         event code format below, showing the information which should be
  2912.         returned to the calling process.
  2913.  
  2914.       Receive
  2915.  
  2916.         Format:  RECEIVE (local connection name, buffer address, byte
  2917.         count)
  2918.  
  2919.         This command allocates a receiving buffer associated with the
  2920.         specified connection.  If no OPEN precedes this command or the
  2921.         calling process is not authorized to use this connection, an
  2922.         error is returned.
  2923.  
  2924.         In the simplest implementation, control would not return to the
  2925.         calling program until either the buffer was filled, or some
  2926.         error occurred, but this scheme is highly subject to deadlocks.
  2927.         A more sophisticated implementation would permit several
  2928.         RECEIVEs to be outstanding at once.  These would be filled as
  2929.         letters, segments or fragments arrive.  This strategy permits
  2930.         increased throughput at the cost of a more elaborate scheme
  2931.         (possibly asynchronous) to notify the calling program that a
  2932.         letter has been received or a buffer filled.
  2933.  
  2934.         If insufficient buffer space is given to reassemble a complete
  2935.         letter, the EOL flag will not be set in the response to the
  2936.         RECEIVE.  The buffer will be filled with as much data as it can
  2937.         hold.  The last buffer required to hold the letter is returned
  2938.         with EOL signaled.
  2939.  
  2940.  
  2941.  
  2942. [Page 46]                                                               
  2943.  
  2944.  
  2945. December 1979                                                           
  2946.                                            Transmission Control Protocol
  2947.                                                 Functional Specification
  2948.  
  2949.  
  2950.  
  2951.         The remaining parts of a partly delivered letter will be placed
  2952.         in buffers as they are made available via successive RECEIVEs.
  2953.         If a number of RECEIVEs are outstanding, they may be filled with
  2954.         parts of a single long letter or with at most one letter each.
  2955.         The event codes associated with each RECEIVE will indicate what
  2956.         is contained in the buffer.
  2957.  
  2958.         If a buffer size was given in the OPEN call, then all buffers
  2959.         presented in RECEIVE calls must be of exactly that size, or an
  2960.         error indication will be returned.
  2961.  
  2962.         The URGENT flag will be set only if the receiving user has
  2963.         previously been informed via a general event, that urgent data
  2964.         is waiting.  The receiving user should thus be in "read-fast"
  2965.         mode.  If the URGENT flag is on, additional urgent data remains.
  2966.         If the URGENT flag is off, this call to RECEIVE has returned all
  2967.         the urgent data, and the user may now leave "read-fast" mode.
  2968.  
  2969.         To distinguish among several outstanding RECEIVEs and to take
  2970.         care of the case that a letter is smaller than the buffer
  2971.         supplied, the event code is accompanied by both a buffer pointer
  2972.         and a byte count indicating the actual length of the letter
  2973.         received.
  2974.  
  2975.         Alternative implementations of RECEIVE might have the TCP
  2976.         allocate buffer storage, or the TCP might share a ring buffer
  2977.         with the user.  Variations of this kind will produce obvious
  2978.         variation in user interface to the TCP.
  2979.  
  2980.       Close
  2981.  
  2982.         Format:  CLOSE(local connection name)
  2983.  
  2984.         This command causes the connection specified to be closed.  If
  2985.         the connection is not open or the calling process is not
  2986.         authorized to use this connection, an error is returned.
  2987.         Closing connections is intended to be a graceful operation in
  2988.         the sense that outstanding SENDs will be transmitted (and
  2989.         retransmitted), as flow control permits, until all have been
  2990.         serviced.  Thus, it should be acceptable to make several SEND
  2991.         calls, followed by a CLOSE, and expect all the data to be sent
  2992.         to the destination.  It should also be clear that users should
  2993.         continue to RECEIVE on CLOSING connections, since the other side
  2994.         may be trying to transmit the last of its data.  Thus, CLOSE
  2995.         means "I have no more to send" but does not mean "I will not
  2996.         receive any more."  It may happen (if the user level protocol is
  2997.         not well thought out) that the closing side is unable to get rid
  2998.  
  2999.  
  3000.  
  3001.                                                                [Page 47]
  3002.  
  3003.  
  3004.                                                            December 1979
  3005. Transmission Control Protocol
  3006. Functional Specification
  3007.  
  3008.  
  3009.  
  3010.         of all its data before timing out.  In this event, CLOSE turns
  3011.         into ABORT, and the closing TCP gives up.
  3012.  
  3013.         The user may CLOSE the connection at any time on his own
  3014.         initiative, or in response to various prompts from the TCP
  3015.         (e.g., remote close executed, transmission timeout exceeded,
  3016.         destination inaccessible).
  3017.  
  3018.         Because closing a connection requires communication with the
  3019.         foreign TCP, connections may remain in the closing state for a
  3020.         short time.  Attempts to reopen the connection before the TCP
  3021.         replies to the CLOSE command will result in error responses.
  3022.  
  3023.         Close also implies end of letter.
  3024.  
  3025.       Status
  3026.  
  3027.         Format:  STATUS(local connection name)
  3028.  
  3029.         This is an implementation dependent user command and could be
  3030.         excluded without adverse effect.  Information returned would
  3031.         typically come from the TCB associated with the connection.
  3032.  
  3033.         This command returns a data block containing the following
  3034.         information:
  3035.  
  3036.           local socket,
  3037.           foreign socket,
  3038.           local connection name,
  3039.           receive window,
  3040.           send window,
  3041.           connection state,
  3042.           number of buffers awaiting acknowledgment,
  3043.           number of buffers pending receipt (including partial ones),
  3044.           receive buffer size,
  3045.           urgent state,
  3046.           precedence,
  3047.           security/compartment,
  3048.           and default transmission timeout.
  3049.  
  3050.         Depending on the state of the connection, or on the
  3051.         implementation itself, some of this information may not be
  3052.         available or meaningful.  If the calling process is not
  3053.         authorized to use this connection, an error is returned.  This
  3054.         prevents unauthorized processes from gaining information about a
  3055.         connection.
  3056.  
  3057.  
  3058.  
  3059.  
  3060. [Page 48]                                                               
  3061.  
  3062.  
  3063. December 1979                                                           
  3064.                                            Transmission Control Protocol
  3065.                                                 Functional Specification
  3066.  
  3067.  
  3068.  
  3069.       Abort
  3070.  
  3071.         Format:  ABORT (local connection name)
  3072.  
  3073.         This command causes all pending SENDs and RECEIVES to be
  3074.         aborted, the TCB to be removed, and a special RESET message to
  3075.         be sent to the TCP on the other side of the connection.
  3076.         Depending on the implementation, users may receive abort
  3077.         indications for each outstanding SEND or RECEIVE, or may simply
  3078.         receive an ABORT-acknowledgment.
  3079.  
  3080.     TCP-to-User Messages
  3081.  
  3082.       It is assumed that the operating system environment provides a
  3083.       means for the TCP to asynchronously signal the user program.  When
  3084.       the TCP does signal a user program, certain information is passed
  3085.       to the user.  Often in the specification the information will be
  3086.       an error message.  In other cases there will be information
  3087.       relating to the completion of processing a SEND or RECEIVE or
  3088.       other user call.
  3089.  
  3090.       The following information is provided:
  3091.  
  3092.         Local Connection Name                    Always
  3093.         Response String                          Always
  3094.         Buffer Address                           Send & Receive
  3095.         Byte count (counts bytes received)       Receive
  3096.         End-of-Letter flag                       Receive
  3097.         End-of-Urgent flag                       Receive
  3098.  
  3099.   TCP/Network Interface
  3100.  
  3101.     The TCP calls on a lower level protocol module to actually send and
  3102.     receive information over a network.  One case is that of the ARPA
  3103.     internetwork system where the lower level module is the Internet
  3104.     Protocol [1].  In most cases the following simple interface would be
  3105.     adequate.
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118.  
  3119.                                                                [Page 49]
  3120.  
  3121.  
  3122.                                                            December 1979
  3123. Transmission Control Protocol
  3124. Functional Specification
  3125.  
  3126.  
  3127.  
  3128.     The following two calls satisfy the requirements for the TCP to
  3129.     internet protocol module communication:
  3130.  
  3131.       SEND (dest, TOS, TTL, BufPTR, len, Id, DF, options => result)
  3132.  
  3133.         where:
  3134.  
  3135.           dest = destination address
  3136.           TOS = type of service
  3137.           TTL = time to live
  3138.           BufPTR = buffer pointer
  3139.           len = length of buffer
  3140.           Id  = Identifier
  3141.           DF = Don't Fragment
  3142.           options = option data
  3143.           result = response
  3144.             OK = datagram sent ok
  3145.             Error = error in arguments or local network error
  3146.  
  3147.         Note that the precedence is included in the TOS and the
  3148.         security/compartment is passed as an option.
  3149.  
  3150.       RECV (BufPTR => result, source, dest, prot, TOS, len)
  3151.  
  3152.         where:
  3153.  
  3154.           BufPTR = buffer pointer
  3155.           result = response
  3156.             OK = datagram received ok
  3157.             Error = error in arguments
  3158.           source = source address
  3159.           dest = destination address
  3160.           prot = protocol
  3161.           TOS = type of service
  3162.           options = option data
  3163.           len = length of buffer
  3164.  
  3165.         Note that the precedence is in the TOS, and the
  3166.         security/compartment is an option.
  3167.  
  3168.       When the TCP sends a segment, it executes the SEND call supplying
  3169.       all the arguments.  The internet protocol module, on receiving
  3170.       this call, checks the arguments and prepares and sends the
  3171.       message.  If the arguments are good and the segment is accepted by
  3172.       the local network, the call returns successfully.  If either the
  3173.       arguments are bad, or the segment is not accepted by the local
  3174.       network, the call returns unsuccessfully.  On unsuccessful
  3175.       returns, a reasonable report should be made as to the cause of the
  3176.  
  3177.  
  3178. [Page 50]                                                               
  3179.  
  3180.  
  3181. December 1979                                                           
  3182.                                            Transmission Control Protocol
  3183.                                                 Functional Specification
  3184.  
  3185.  
  3186.  
  3187.       problem, but the details of such reports are up to individual
  3188.       implementations.
  3189.  
  3190.       When a segment arrives at the internet protocol module from the
  3191.       local network, either there is a pending RECV call from TCP or
  3192.       there is not.  In the first case, the pending call is satisfied by
  3193.       passing the information from the segment to the TCP.  In the
  3194.       second case, the TCP is notified of a pending segment.
  3195.  
  3196.       The notification of a TCP may be via a pseudo interrupt or similar
  3197.       mechanism, as appropriate in the particular operating system
  3198.       environment of the implementation.
  3199.  
  3200.       A TCP's RECV call may then either be immediately satisfied by a
  3201.       pending segment, or the call may be pending until a segment
  3202.       arrives.
  3203.  
  3204.       We note that the Internet Protocol provides arguments for a type
  3205.       of service and for a time to live.  TCP uses the following
  3206.       settings for these parameters:
  3207.  
  3208.         Type of Service = Precedence:  none, Package:  stream,
  3209.         Reliability:  higher, Preference:  speed, Speed:  higher; or
  3210.         00011111.
  3211.  
  3212.         Time to Live    = one minute, or 00111100.
  3213.  
  3214.           Note that the assumed maximum segment lifetime is two minutes.
  3215.           Here we explicitly ask that a segment be destroyed if it
  3216.           cannot be delivered by the internet system within one minute.
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.                                                                [Page 51]
  3238.  
  3239.  
  3240.                                                            December 1979
  3241. Transmission Control Protocol
  3242. Functional Specification
  3243.  
  3244.  
  3245.  
  3246. 3.9.  Event Processing
  3247.  
  3248.   The activity of the TCP can be characterized as responding to events.
  3249.   The events that occur can be cast into three categories:  user calls,
  3250.   arriving segments, and timeouts.  This section describes the
  3251.   processing the TCP does in response to each of the events.  In many
  3252.   cases the processing required depends on the state of the connection.
  3253.  
  3254.     Events that occur:
  3255.  
  3256.       User Calls
  3257.  
  3258.         OPEN
  3259.         SEND
  3260.         RECEIVE
  3261.         CLOSE
  3262.         ABORT
  3263.         STATUS
  3264.  
  3265.       Arriving Segments
  3266.  
  3267.         SEGMENT ARRIVES
  3268.  
  3269.       Timeouts
  3270.  
  3271.         USER TIMEOUT
  3272.         RETRANSMISSION TIMEOUT
  3273.  
  3274.   The model of the TCP/user interface is that user commands receive an
  3275.   immediate return and possibly a delayed response via an event or
  3276.   pseudo interrupt.  In the following descriptions, the term "signal"
  3277.   means cause a delayed response.
  3278.  
  3279.   Error responses are given as character strings.  For example, user
  3280.   commands referencing connections that do not exist receive "error:
  3281.   connection not open".
  3282.  
  3283.   Please note in the following that all arithmetic on sequence numbers,
  3284.   acknowledgment numbers, windows, et cetera, is modulo 2**32 the size
  3285.   of the sequence number space.  Also note that "=<" means less than or
  3286.   equal to.
  3287.  
  3288.   A natural way to think about processing incoming segments is to
  3289.   imagine that they are first tested for proper sequence number (i.e.,
  3290.   that their contents lie in the range of the expected "receive window"
  3291.   in the sequence number space) and then that they are generally queued
  3292.   and processed in sequence number order.
  3293.  
  3294.  
  3295.  
  3296. [Page 52]                                                               
  3297.  
  3298.  
  3299. December 1979                                                           
  3300.                                            Transmission Control Protocol
  3301.                                                 Functional Specification
  3302.  
  3303.  
  3304.  
  3305.   When a segment overlaps other already received segments we reconstruct
  3306.   the segment to contain just the new data, and adjust the header fields
  3307.   to be consistent.
  3308.  
  3309.  
  3310.  
  3311.  
  3312.  
  3313.  
  3314.  
  3315.  
  3316.  
  3317.  
  3318.  
  3319.  
  3320.  
  3321.  
  3322.  
  3323.  
  3324.  
  3325.  
  3326.  
  3327.  
  3328.  
  3329.  
  3330.  
  3331.  
  3332.  
  3333.  
  3334.  
  3335.  
  3336.  
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.                                                                [Page 53]
  3356.  
  3357.  
  3358.                                                            December 1979
  3359. Transmission Control Protocol
  3360. Functional Specification
  3361.                                                                OPEN Call
  3362.  
  3363.  
  3364.  
  3365.   OPEN Call
  3366.  
  3367.     CLOSED STATE (i.e., TCB does not exist)
  3368.  
  3369.       Create a new transmission control block (TCB) to hold connection
  3370.       state information.  Fill in local socket identifier, foreign
  3371.       socket, precedence, security/compartment, and user timeout
  3372.       information.  Verify the security and precedence requested are
  3373.       allowed for this user, if not return "error:  precedence not
  3374.       allowed" or "error:  security/compartment not allowed."  If active
  3375.       and the foreign socket is unspecified, return "error:  foreign
  3376.       socket unspecified"; if active and the foreign socket is
  3377.       specified, issue a SYN segment.  An initial send sequence number
  3378.       (ISS) is selected and a SYN segment of the form <SEQ=ISS><CTL=SYN>
  3379.       is sent.  Set SND.UNA to ISS, SND.NXT to ISS+1, SND.LBB to ISS+1,
  3380.       enter SYN-SENT state, and return.
  3381.  
  3382.       If the caller does not have access to the local socket specified,
  3383.       return "error:  connection illegal for this process".  If there is
  3384.       no room to create a new connection, return "error:  insufficient
  3385.       resources".
  3386.  
  3387.     LISTEN STATE
  3388.     SYN-SENT STATE
  3389.     SYN-RECEIVED STATE
  3390.     ESTABLISHED STATE
  3391.     FIN-WAIT-1 STATE
  3392.     FIN-WAIT-2 STATE
  3393.     TIME-WAIT STATE
  3394.     CLOSE-WAIT STATE
  3395.     CLOSING STATE
  3396.  
  3397.       Return "error:  connection already exists".
  3398.  
  3399.  
  3400.  
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414. [Page 54]                                                               
  3415.  
  3416.  
  3417. December 1979                                                           
  3418.                                            Transmission Control Protocol
  3419.                                                 Functional Specification
  3420. SEND Call
  3421.  
  3422.  
  3423.  
  3424.   SEND Call
  3425.  
  3426.     CLOSED STATE (i.e., TCB does not exist)
  3427.  
  3428.       If the user should no have access to such a connection, then
  3429.       return "error:  connection illegal for this process".
  3430.  
  3431.       Otherwise, return "error:  connection does not exist".
  3432.  
  3433.     LISTEN STATE
  3434.  
  3435.       If the foreign socket is specified, then change the connection
  3436.       from passive to active, select an ISS, send a SYN segment, set
  3437.       SND.UNA to ISS, SND.NXT to ISS+1 and SND.LBB to ISS+1.  Enter
  3438.       SYN-SENT state.  Data associated with SEND may be sent with SYN
  3439.       segment or queued for transmission after entering ESTABLISHED
  3440.       state.  The urgent bit if requested in the command should be sent
  3441.       with the first data segment sent as a result of this command.  If
  3442.       there is no room to queue the request, respond with "error:
  3443.       insufficient resources".  If Foreign socket was not specified,
  3444.       then return "error:  foreign socket unspecified".
  3445.  
  3446.     SYN-SENT STATE
  3447.  
  3448.       Queue for processing after the connection is ESTABLISHED.
  3449.       Typically, nothing can be sent yet, anyway, because the send
  3450.       window has not yet been set by the other side.  If no space,
  3451.       return "error:  insufficient resources".
  3452.  
  3453.     SYN-RECEIVED STATE
  3454.  
  3455.       Queue for later processing after entering ESTABLISHED state.  If
  3456.       no space to queue, respond with "error:  insufficient resources".
  3457.  
  3458.     ESTABLISHED STATE
  3459.  
  3460.       Segmentize the buffer, send or queue it for output, with a
  3461.       piggybacked acknowledgment (acknowledgment value = SND.UNA) with
  3462.       the data (this is not required, but there is no advantage in not
  3463.       doing so).  If there is insufficient space to remember this
  3464.       buffer, simply return "error:  insufficient resources".
  3465.  
  3466.       If remote buffer size is not one octet, then, if this is the end
  3467.       of a letter, do the following end-of-letter/buffer-size adjustment
  3468.       processing:
  3469.  
  3470.  
  3471.  
  3472.  
  3473.                                                                [Page 55]
  3474.  
  3475.  
  3476.                                                            December 1979
  3477. Transmission Control Protocol
  3478. Functional Specification
  3479.                                                                SEND Call
  3480.  
  3481.  
  3482.  
  3483.         if EOL = 0 then
  3484.  
  3485.           SND.NXT <- SEG.SEQ + SEG.LEN
  3486.  
  3487.         if EOL = 1 then
  3488.  
  3489.           While SND.LBB < SEG.SEQ + SEG.LEN
  3490.           Do SND.LBB <- SND.LBB + SND.BS End
  3491.           SND.NXT <- SND.LBB
  3492.  
  3493.       If the urgent flag is set, then SND.UP <- SND.NXT-1 and set the
  3494.       urgent pointer in the outgoing segment.
  3495.  
  3496.     FIN-WAIT-1 STATE
  3497.     FIN-WAIT-2 STATE
  3498.     TIME-WAIT STATE
  3499.  
  3500.       Return "error:  connection closing" and do not service request.
  3501.  
  3502.     CLOSE-WAIT STATE
  3503.  
  3504.       Segmentize any text to be sent and queue for output.  If there is
  3505.       insufficient space to remember the SEND, return "error:
  3506.       insufficient resources"
  3507.  
  3508.     CLOSING STATE
  3509.  
  3510.       Respond with "error:  connection closing"
  3511.  
  3512.  
  3513.  
  3514.  
  3515.  
  3516.  
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532. [Page 56]                                                               
  3533.  
  3534.  
  3535. December 1979                                                           
  3536.                                            Transmission Control Protocol
  3537.                                                 Functional Specification
  3538. RECEIVE Call
  3539.  
  3540.  
  3541.  
  3542.   RECEIVE Call
  3543.  
  3544.     CLOSED STATE (i.e., TCB does not exist)
  3545.  
  3546.       If the user should no have access to such a connection, return
  3547.       "error:  connection illegal for this process".
  3548.  
  3549.       Otherwise return "error:  connection does not exist".
  3550.  
  3551.     LISTEN STATE
  3552.     SYN-SENT STATE
  3553.     SYN-RECEIVED STATE
  3554.  
  3555.       Queue for processing after entering ESTABLISHED state.  If there
  3556.       is no room to queue this request, respond with "error:
  3557.       insufficient resources".
  3558.  
  3559.     ESTABLISHED STATE
  3560.  
  3561.       If insufficient incoming segments are queued to satisfy the
  3562.       request, queue the request.  If there is no queue space to
  3563.       remember the RECEIVE, respond with "error:  insufficient
  3564.       resources".
  3565.  
  3566.       Reassemble queued incoming segments into receive buffer and return
  3567.       to user.  Mark "end of letter" (EOL) if this is the case.
  3568.  
  3569.       If RCV.UP is in advance of the data currently being passed to the
  3570.       user notify the user of the presence of urgent data.
  3571.  
  3572.       When the TCP takes responsibility for delivering data to the user
  3573.       that fact must be communicated to the sender via an
  3574.       acknowledgment.  The formation of such an acknowledgment is
  3575.       described below in the discussion of processing an incoming
  3576.       segment.
  3577.  
  3578.     FIN-WAIT-1 STATE
  3579.     FIN-WAIT-2 STATE
  3580.  
  3581.       Reassemble and return a letter, or as much as will fit, in the
  3582.       user buffer.  Queue the request if it cannot be serviced
  3583.       immediately.
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.                                                                [Page 57]
  3592.  
  3593.  
  3594.                                                            December 1979
  3595. Transmission Control Protocol
  3596. Functional Specification
  3597.                                                             RECEIVE Call
  3598.  
  3599.  
  3600.  
  3601.     TIME-WAIT STATE
  3602.     CLOSE-WAIT STATE
  3603.  
  3604.       Since the remote side has already sent FIN, RECEIVEs must be
  3605.       satisfied by text already reassembled, but not yet delivered to
  3606.       the user.  If no reassembled segment text is awaiting delivery,
  3607.       the RECEIVE should get a "error:  connection closing" response.
  3608.       Otherwise, any remaining text can be used to satisfy the RECEIVE.
  3609.  
  3610.     CLOSING STATE
  3611.  
  3612.       Return "error:  connection closing"
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.  
  3635.  
  3636.  
  3637.  
  3638.  
  3639.  
  3640.  
  3641.  
  3642.  
  3643.  
  3644.  
  3645.  
  3646.  
  3647.  
  3648.  
  3649.  
  3650. [Page 58]                                                               
  3651.  
  3652.  
  3653. December 1979                                                           
  3654.                                            Transmission Control Protocol
  3655.                                                 Functional Specification
  3656. CLOSE Call
  3657.  
  3658.  
  3659.  
  3660.   CLOSE Call
  3661.  
  3662.     CLOSED STATE (i.e., TCB does not exist)
  3663.  
  3664.       If the user should no have access to such a connection, return
  3665.       "error:  connection illegal for this process".
  3666.  
  3667.       Otherwise, return "error:  connection does not exist".
  3668.  
  3669.     LISTEN STATE
  3670.  
  3671.       Any outstanding RECEIVEs should be returned with "error:  closing"
  3672.       responses.  Delete TCB, return "ok".
  3673.  
  3674.     SYN-SENT STATE
  3675.  
  3676.       Delete the TCB and return "error:  closing" responses to any
  3677.       queued SENDs, or RECEIVEs.
  3678.  
  3679.     SYN-RECEIVED STATE
  3680.  
  3681.       Queue for processing after entering ESTABLISHED state or
  3682.       segmentize and send FIN segment.  If the latter, enter FIN-WAIT-1
  3683.       state.
  3684.  
  3685.     ESTABLISHED STATE
  3686.  
  3687.       Queue this until all preceding SENDs have been segmentized, then
  3688.       form a FIN segment and send it.  In any case, enter FIN-WAIT-1
  3689.       state.
  3690.  
  3691.     FIN-WAIT-1 STATE
  3692.     FIN-WAIT-2 STATE
  3693.  
  3694.       Strictly speaking, this is an error and should receive a "error:
  3695.       connection closing" response.  An "ok" response would be
  3696.       acceptable, too, as long as a second FIN is not emitted (the first
  3697.       FIN may be retransmitted though).
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.  
  3705.  
  3706.  
  3707.  
  3708.  
  3709.                                                                [Page 59]
  3710.  
  3711.  
  3712.                                                            December 1979
  3713. Transmission Control Protocol
  3714. Functional Specification
  3715.                                                               CLOSE Call
  3716.  
  3717.  
  3718.  
  3719.     TIME-WAIT STATE
  3720.  
  3721.       Strictly speaking, this is an error and should receive a "error:
  3722.       connection closing" response.  An "ok" response would be
  3723.       acceptable, too.  However, since the FIN has been sent and
  3724.       acknowledged, nothing should be sent (or retransmitted).
  3725.  
  3726.     CLOSE-WAIT STATE
  3727.  
  3728.       Queue this request until all preceding SENDs have been
  3729.       segmentized; then send a FIN segment, enter CLOSING state.
  3730.  
  3731.     CLOSING STATE
  3732.  
  3733.       Respond with "error:  connection closing"
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.  
  3741.  
  3742.  
  3743.  
  3744.  
  3745.  
  3746.  
  3747.  
  3748.  
  3749.  
  3750.  
  3751.  
  3752.  
  3753.  
  3754.  
  3755.  
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.  
  3767.  
  3768. [Page 60]                                                               
  3769.  
  3770.  
  3771. December 1979                                                           
  3772.                                            Transmission Control Protocol
  3773.                                                 Functional Specification
  3774. ABORT Call
  3775.  
  3776.  
  3777.  
  3778.   ABORT Call
  3779.  
  3780.     CLOSED STATE (i.e., TCB does not exist)
  3781.  
  3782.       If the user should no have access to such a connection, return
  3783.       "error:  connection illegal for this process".
  3784.  
  3785.       Otherwise return "error:  connection does not exist".
  3786.  
  3787.     LISTEN STATE
  3788.  
  3789.       Any outstanding RECEIVEs should be returned with "error:
  3790.       connection reset" responses.  Delete TCB, return "ok".
  3791.  
  3792.     SYN-SENT STATE
  3793.  
  3794.       Delete the TCB and return "reset" responses to any queued SENDs,
  3795.       or RECEIVEs.
  3796.  
  3797.     SYN-RECEIVED STATE
  3798.  
  3799.       Send a RST of the form:
  3800.  
  3801.         <SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
  3802.  
  3803.       and return any unprocessed SENDs, or RECEIVEs with "reset" code,
  3804.       delete the TCB.
  3805.  
  3806.     ESTABLISHED STATE
  3807.  
  3808.       Send a reset segment:
  3809.  
  3810.         <SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
  3811.  
  3812.       All queued SENDs and RECEIVEs should be given "reset" responses;
  3813.       all segments queued for transmission (except for the RST formed
  3814.       above) or retransmission should be flushed, delete the TCB.
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826.  
  3827.                                                                [Page 61]
  3828.  
  3829.  
  3830.                                                            December 1979
  3831. Transmission Control Protocol
  3832. Functional Specification
  3833.                                                               ABORT Call
  3834.  
  3835.  
  3836.  
  3837.     FIN-WAIT-1 STATE
  3838.     FIN-WAIT-2 STATE
  3839.  
  3840.       A reset segment (RST) should be formed and sent:
  3841.  
  3842.         <SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
  3843.  
  3844.       Outstanding SENDs, RECEIVEs, CLOSEs, and/or segments queued for
  3845.       retransmission, or segmentizing, should be flushed, with
  3846.       "connection reset" notification to the user, delete the TCB.
  3847.  
  3848.     TIME-WAIT STATE
  3849.  
  3850.       Respond with "ok" and delete the TCB.
  3851.  
  3852.     CLOSE-WAIT STATE
  3853.  
  3854.       Flush any pending SENDs and RECEIVEs, returning "connection reset"
  3855.       responses for them.  Form and send a RST segment:
  3856.  
  3857.         <SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
  3858.  
  3859.       Flush all segment queues and delete the TCB.
  3860.  
  3861.     CLOSING STATE
  3862.  
  3863.       Respond with "ok" and delete the TCB; flush any remaining segment
  3864.       queues.  If a CLOSE command is still pending, respond "error:
  3865.       connection reset".
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.  
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886. [Page 62]                                                               
  3887.  
  3888.  
  3889. December 1979                                                           
  3890.                                            Transmission Control Protocol
  3891.                                                 Functional Specification
  3892. STATUS Call
  3893.  
  3894.  
  3895.  
  3896.   STATUS Call
  3897.  
  3898.     CLOSED STATE (i.e., TCB does not exist)
  3899.  
  3900.       If the user should no have access to such a connection, return
  3901.       "error:  connection illegal for this process".
  3902.  
  3903.       Otherwise return "error:  connection does not exist".
  3904.  
  3905.     LISTEN STATE
  3906.  
  3907.       Return "state = LISTEN", and the TCB pointer.
  3908.  
  3909.     SYN-SENT STATE
  3910.  
  3911.       Return "state = SYN-SENT", and the TCB pointer.
  3912.  
  3913.     SYN-RECEIVED STATE
  3914.  
  3915.       Return "state = SYN-RECEIVED", and the TCB pointer.
  3916.  
  3917.     ESTABLISHED STATE
  3918.  
  3919.       Return "state = ESTABLISHED", and the TCB pointer.
  3920.  
  3921.     FIN-WAIT-1 STATE
  3922.  
  3923.       Return "state = FIN-WAIT-1", and the TCB pointer.
  3924.  
  3925.     FIN-WAIT-2 STATE
  3926.  
  3927.       Return "state = FIN-WAIT-2", and the TCB pointer.
  3928.  
  3929.     TIME-WAIT STATE
  3930.  
  3931.       Return "state = TIME-WAIT and the TCB pointer.
  3932.  
  3933.     CLOSE-WAIT STATE
  3934.  
  3935.       Return "state = CLOSE-WAIT", and the TCB pointer.
  3936.  
  3937.     CLOSING STATE
  3938.  
  3939.       Return "state = CLOSING", and the TCB pointer.
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.                                                                [Page 63]
  3946.  
  3947.  
  3948.                                                            December 1979
  3949. Transmission Control Protocol
  3950. Functional Specification
  3951.                                                          SEGMENT ARRIVES
  3952.  
  3953.  
  3954.  
  3955.   SEGMENT ARRIVES
  3956.  
  3957.     If the state is CLOSED (i.e., TCB does not exist) then
  3958.  
  3959.       all data in the incoming segment is discarded.  An incoming
  3960.       segment containing a RST is discarded.  An incoming segment not
  3961.       containing a RST causes a RST to be sent in response.  The
  3962.       acknowledgment and sequence field values are selected to make the
  3963.       reset sequence acceptable to the TCP that sent the offending
  3964.       segment.
  3965.  
  3966.       If the ACK bit is off, sequence number zero is used,
  3967.  
  3968.         <SEQ=0><ACK=SEG.SEQ+SEG.LEN><CTL=RST,ACK>
  3969.  
  3970.       If the ACK bit is on,
  3971.  
  3972.         <SEQ=SEG.ACK><CTL=RST>
  3973.  
  3974.       Return.
  3975.  
  3976.     If the state is LISTEN then
  3977.  
  3978.       first check for an ACK
  3979.  
  3980.         Any acknowledgment is bad if it arrives on a connection still in
  3981.         the LISTEN state.  An acceptable reset segment should be formed
  3982.         for any arriving ACK-bearing segment, except another RST.  The
  3983.         RST should be formatted as follows:
  3984.  
  3985.           <SEQ=SEG.ACK><CTL=RST>
  3986.  
  3987.         Return.
  3988.  
  3989.         An incoming RST should be ignored.  Return.
  3990.  
  3991.       if there was no ACK then check for a SYN
  3992.  
  3993.         If the SYN bit is set, check the security.  If the
  3994.         security/compartment on the incoming segment does not exactly
  3995.         match the security/compartment in the TCB then send a reset and
  3996.         return and check the precedence.  If the SEG.PRC is less than
  3997.         the TCB.PRC then send a reset and return.  If the SEG.PRC is
  3998.         greater than the TCB.PRC then set TCB.PRC<-SEG.PRC.  Now RCV.NXT
  3999.         and RCV.LBB are set to SEG.SEQ+1, IRS is set to SEG.SEQ and any
  4000.         other control or text should be queued for processing later.
  4001.         ISS should be selected and a SYN segment sent of the form:
  4002.  
  4003.  
  4004. [Page 64]                                                               
  4005.  
  4006.  
  4007. December 1979                                                           
  4008.                                            Transmission Control Protocol
  4009.                                                 Functional Specification
  4010. SEGMENT ARRIVES
  4011.  
  4012.  
  4013.  
  4014.           <SEQ=ISS><ACK=RCV.NXT><CTL=SYN,ACK>
  4015.  
  4016.         SND.NXT and SND.LBB are set to ISS+1 and SND.UNA to ISS.  The
  4017.         connection state should be changed to SYN-RECEIVED.  Note that
  4018.         any other incoming control or data (combined with SYN) will be
  4019.         processed in the SYN-RECEIVED state, but processing of SYN and
  4020.         ACK should not be repeated.
  4021.  
  4022.         This segment may also include data and control bits (e.g., URG,
  4023.         EOL) which were queued for transmission.
  4024.  
  4025.       if there was no SYN but there was other text or control
  4026.  
  4027.         Any other control or text-bearing segment (not containing SYN)
  4028.         should have an ACK and thus would be discarded by the ACK
  4029.         processing.  An incoming RST segment could not be valid, since
  4030.         it could not have been sent in response to anything sent by this
  4031.         incarnation of the connection.  So you are unlikely to get here,
  4032.         but if you do, drop the segment, and return.
  4033.  
  4034.     If the state is SYN-SENT then
  4035.  
  4036.       first check for an ACK
  4037.  
  4038.         If SEG.ACK =< ISS, or SEG.ACK > SND.NXT, or the
  4039.         security/compartment in the segment does not exactly match the
  4040.         security/compartment in the TCB, or the precedence in the
  4041.         segment is less than the precedence in the TCB, send a reset
  4042.  
  4043.           <SEQ=SEG.ACK><CTL=RST>
  4044.  
  4045.         and discard the segment.  Return.
  4046.  
  4047.         If SND.UNA =< SEG.ACK =< SND.NXT and the security/compartment
  4048.         and precedence are acceptable then the ACK is acceptable.
  4049.         SND.UNA should be advanced to equal SEG.ACK, and any segments on
  4050.         the retransmission queue which are thereby acknowledged should
  4051.         be removed.
  4052.  
  4053.       if the ACK is ok (or there is no ACK), check the RST bit
  4054.  
  4055.         If the RST bit is set then signal the user "error:  connection
  4056.         reset", enter CLOSED state, drop the segment, delete TCB, and
  4057.         return.
  4058.  
  4059.       if the ACK is ok (or there is no ACK) and it was not a RST, check
  4060.       the SYN bit
  4061.  
  4062.  
  4063.                                                                [Page 65]
  4064.  
  4065.  
  4066.                                                            December 1979
  4067. Transmission Control Protocol
  4068. Functional Specification
  4069.                                                          SEGMENT ARRIVES
  4070.  
  4071.  
  4072.  
  4073.         If the SYN bit is on and the security/compartment and precedence
  4074.         are acceptable then, RCV.NXT and RCV.LBB are set to SEG.SEQ+1,
  4075.         IRS is set to SEG.SEQ.  If SND.UNA > ISS (our SYN has been
  4076.         ACKed), change the connection state to ESTABLISHED, otherwise
  4077.         enter SYN-RECEIVED.  In any case, form an ACK segment:
  4078.  
  4079.           <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK>
  4080.  
  4081.         and send it.  Data or controls which were queued for
  4082.         transmission may be included.
  4083.  
  4084.         If SEG.PRC is greater than TCB.PRC set TCB.PRC<-SEG.PRC.
  4085.  
  4086.         If there are other controls or text in the segment then continue
  4087.         processing at the fifth step below where the URG bit is checked,
  4088.         otherwise return.
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097.  
  4098.  
  4099.  
  4100.  
  4101.  
  4102.  
  4103.  
  4104.  
  4105.  
  4106.  
  4107.  
  4108.  
  4109.  
  4110.  
  4111.  
  4112.  
  4113.  
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122. [Page 66]                                                               
  4123.  
  4124.  
  4125. December 1979                                                           
  4126.                                            Transmission Control Protocol
  4127.                                                 Functional Specification
  4128. SEGMENT ARRIVES
  4129.  
  4130.  
  4131.  
  4132.     Otherwise,
  4133.  
  4134.     first check sequence number
  4135.  
  4136.       SYN-RECEIVED STATE
  4137.       ESTABLISHED STATE
  4138.       FIN-WAIT-1 STATE
  4139.       FIN-WAIT-2 STATE
  4140.       TIME-WAIT STATE
  4141.       CLOSE-WAIT STATE
  4142.       CLOSING STATE
  4143.  
  4144.         Segments are processed in sequence.  Initial tests on arrival
  4145.         are used to discard old duplicates, but further processing is
  4146.         done in SEG.SEQ order.  If a segment's contents straddle the
  4147.         boundary between old and new, only the new parts should be
  4148.         processed.
  4149.  
  4150.         There are four cases for the acceptability test for an incoming
  4151.         segment:
  4152.  
  4153.         Segment Receive  Test
  4154.         Length  Window
  4155.         ------- -------  -------------------------------------------
  4156.  
  4157.            0       0     SEG.SEQ = RCV.NXT
  4158.  
  4159.            0      >0     RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND
  4160.  
  4161.           >0       0     not acceptable
  4162.  
  4163.           >0      >0     RCV.NXT < SEG.SEQ+SEG.LEN =< RCV.NXT+RCV.WND
  4164.  
  4165.         Note that the test above guarantees that the last sequence
  4166.         number used by the segment lies in the receive-window.  If the
  4167.         RCV.WND is zero, no segments will be acceptable, but special
  4168.         allowance should be made to accept valid ACKs.
  4169.  
  4170.         If an incoming segment is not acceptable, an acknowledgment
  4171.         should be sent in reply:
  4172.  
  4173.           <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK>
  4174.  
  4175.         If the incoming segment is unacceptable, drop it and return.
  4176.  
  4177.  
  4178.  
  4179.  
  4180.  
  4181.                                                                [Page 67]
  4182.  
  4183.  
  4184.                                                            December 1979
  4185. Transmission Control Protocol
  4186. Functional Specification
  4187.                                                          SEGMENT ARRIVES
  4188.  
  4189.  
  4190.  
  4191.     second check security and precedence
  4192.  
  4193.       If the security/compartment and precedence in the segment do not
  4194.       exactly match the security/compartment and precedence in the TCB
  4195.       then form a reset and return.
  4196.  
  4197.       Note this check is placed following the sequence check to prevent
  4198.       a segment from an old connection between these parts with a
  4199.       different security or precedence from causing an abort of the
  4200.       current connection.
  4201.  
  4202.     third check the ACK field,
  4203.  
  4204.       SYN-RECEIVED STATE
  4205.  
  4206.         If the RST bit is off and SND.UNA < SEG.ACK =< SND.NXT then set
  4207.         SND.UNA <- SEG.ACK, remove any acknowledged segments from the
  4208.         retransmission queue, and enter ESTABLISHED state.
  4209.  
  4210.         If the segment acknowledgment is not acceptable, form a reset
  4211.         segment,
  4212.  
  4213.           <SEQ=SEG.ACK><CTL=RST>
  4214.  
  4215.         and send it, unless the incoming segment is an RST (or there is
  4216.         no ACK), in which case, it should be discarded, then return.
  4217.  
  4218.       ESTABLISHED STATE
  4219.  
  4220.         If SND.UNA < SEG.ACK =< SND.NXT then, set SND.UNA <- SEG.ACK.
  4221.         Any segments on the retransmission queue which are thereby
  4222.         entirely acknowledged are removed.  Users should receive
  4223.         positive acknowledgments for buffers which have been SENT and
  4224.         fully acknowledged (i.e., SEND buffer should be returned with
  4225.         "ok" response).  If the ACK is a duplicate, it can be ignored.
  4226.  
  4227.         If the segment passes the sequence number and acknowledgment
  4228.         number tests, the send window should be updated.  If
  4229.         SND.WL =< SEG.SEQ, set SND.WND <- SEG.WND and set
  4230.         SND.WL <- SEG.SEQ.
  4231.  
  4232.         If the remote buffer size is not one, then the
  4233.         end-of-letter/buffer-size adjustment to sequence numbers may
  4234.         have an effect on the next expected sequence number to be
  4235.         acknowledged.  It is possible that the remote TCP will
  4236.         acknowledge with a SEG.ACK equal to a sequence number of an
  4237.  
  4238.  
  4239.  
  4240. [Page 68]                                                               
  4241.  
  4242.  
  4243. December 1979                                                           
  4244.                                            Transmission Control Protocol
  4245.                                                 Functional Specification
  4246. SEGMENT ARRIVES
  4247.  
  4248.  
  4249.  
  4250.         octet that was skipped over at the end of a letter.  This a mild
  4251.         error on the remote TCPs part, but not cause for alarm.
  4252.  
  4253.       FIN-WAIT-1 STATE
  4254.       FIN-WAIT-2 STATE
  4255.  
  4256.         In addition to the processing for the ESTABLISHED state, if the
  4257.         retransmission queue is empty, the user's CLOSE can be
  4258.         acknowledged ("ok") but do not delete the TCB.
  4259.  
  4260.       TIME-WAIT STATE
  4261.  
  4262.         The only thing that can arrive in this state is a retransmission
  4263.         of the remote FIN.  Acknowledge it, and restart the 2 MSL
  4264.         timeout.
  4265.  
  4266.       CLOSE-WAIT STATE
  4267.       CLOSING STATE
  4268.  
  4269.         Do the same processing as for the ESTABLISHED state.
  4270.  
  4271.     fourth check the RST bit,
  4272.  
  4273.       SYN-RECEIVED STATE
  4274.  
  4275.         If the RST bit is set then, if the segment has passed sequence
  4276.         and acknowledgment tests, it is valid.  If this connection was
  4277.         initiated with a passive OPEN (i.e., came from the LISTEN
  4278.         state), then return this connection to LISTEN state.  The user
  4279.         need not be informed.  If this connection was initiated with an
  4280.         active OPEN (i.e., came from SYN-SENT state) then the connection
  4281.         was refused, signal the user "connection refused".  In either
  4282.         case, all segments on the retransmission queue should be
  4283.         removed.
  4284.  
  4285.       ESTABLISHED
  4286.       FIN-WAIT-1
  4287.       FIN-WAIT-2
  4288.       CLOSE-WAIT
  4289.       CLOSING STATE
  4290.  
  4291.         If the RST bit is set then, any outstanding RECEIVEs and SEND
  4292.         should receive "reset" responses.  All segment queues should be
  4293.         flushed.  Users should also receive an unsolicited general
  4294.         "connection reset" signal.  Enter the CLOSED state, delete the
  4295.         TCB, and return.
  4296.  
  4297.  
  4298.  
  4299.                                                                [Page 69]
  4300.  
  4301.  
  4302.                                                            December 1979
  4303. Transmission Control Protocol
  4304. Functional Specification
  4305.                                                          SEGMENT ARRIVES
  4306.  
  4307.  
  4308.  
  4309.       TIME-WAIT
  4310.  
  4311.         Enter the CLOSED state, delete the TCB, and return.
  4312.  
  4313.     fifth, check the SYN bit,
  4314.  
  4315.       SYN-RECEIVED
  4316.       ESTABLISHED STATE
  4317.  
  4318.         If the SYN bit is set, check the segment sequence number against
  4319.         the receive window.  The segment sequence number must be in the
  4320.         receive window; if not, ignore the segment.  If the SYN is on
  4321.         and SEG.SEQ = RCV.NXT-1, then everything is ok and no action is
  4322.         needed; but if they are not equal, there is an error and a reset
  4323.         must be sent.
  4324.  
  4325.           If a reset must be sent it is formed as follows:
  4326.  
  4327.             <SEQ=SEG.ACK><CTL=RST>
  4328.  
  4329.           The connection must be aborted as if a RST had been received.
  4330.  
  4331.       FIN-WAIT STATE-1
  4332.       FIN-WAIT STATE-2
  4333.       TIME-WAIT STATE
  4334.       CLOSE-WAIT STATE
  4335.       CLOSING STATE
  4336.  
  4337.         This case should not occur, since a duplicate of the SYN which
  4338.         started the current connection incarnation will have been
  4339.         filtered in the SEG.SEQ processing.  Other SYN's will have been
  4340.         rejected by this test as well (see SYN processing for
  4341.         ESTABLISHED state).
  4342.  
  4343.     sixth, check the URG bit,
  4344.  
  4345.       ESTABLISHED STATE
  4346.       FIN-WAIT-1 STATE
  4347.       FIN-WAIT-2 STATE
  4348.  
  4349.         If the URG bit is set, RCV.UP <- max(RCV.UP,SEG.UP), and signal
  4350.         the user that the remote side has urgent data if the urgent
  4351.         pointer (RCV.UP) is in advance of the data consumed.  If the
  4352.         user has already been signaled (or is still in the "urgent
  4353.         mode") for this continuous sequence of urgent data, do not
  4354.         signal the user again.
  4355.  
  4356.  
  4357.  
  4358. [Page 70]                                                               
  4359.  
  4360.  
  4361. December 1979                                                           
  4362.                                            Transmission Control Protocol
  4363.                                                 Functional Specification
  4364. SEGMENT ARRIVES
  4365.  
  4366.  
  4367.  
  4368.       TIME-WAIT STATE
  4369.       CLOSE-WAIT STATE
  4370.       CLOSING
  4371.  
  4372.         This should not occur, since a FIN has been received from the
  4373.         remote side.  Ignore the URG.
  4374.  
  4375.     seventh, process the segment text,
  4376.  
  4377.       ESTABLISHED STATE
  4378.  
  4379.         Once in the ESTABLISHED state, it is possible to deliver segment
  4380.         text to user RECEIVE buffers.  Text from segments can be moved
  4381.         into buffers until either the buffer is full or the segment is
  4382.         empty.  If the segment empties and carries an EOL flag, then the
  4383.         user is informed, when the buffer is returned, that an EOL has
  4384.         been received.
  4385.  
  4386.         If buffer size is not one octet, then do  the following
  4387.         end-of-letter/buffer-size adjustment processing:
  4388.  
  4389.           if EOL = 0 then
  4390.  
  4391.             RCV.NXT <- SEG.SEQ + SEG.LEN
  4392.  
  4393.           if EOL = 1 then
  4394.  
  4395.             While RCV.LBB < SEG.SEQ+SEG.LEN
  4396.             Do RCV.LBB <- RCV.LBB + RCV.BS End
  4397.             RCV.NXT <- RCV.LBB
  4398.  
  4399.         When the TCP takes responsibility for delivering the data to the
  4400.         user it must also acknowledge the receipt of the data.  Send an
  4401.         acknowledgment of the form:
  4402.  
  4403.           <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK>
  4404.  
  4405.         This acknowledgment should be piggybacked on a segment being
  4406.         transmitted if possible without incurring undue delay.
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.                                                                [Page 71]
  4418.  
  4419.  
  4420.                                                            December 1979
  4421. Transmission Control Protocol
  4422. Functional Specification
  4423.                                                          SEGMENT ARRIVES
  4424.  
  4425.  
  4426.  
  4427.       FIN-WAIT-1 STATE
  4428.       FIN-WAIT-2 STATE
  4429.  
  4430.         If there are outstanding RECEIVEs, they should be satisfied, if
  4431.         possible, with the text of this segment; remaining text should
  4432.         be queued for further processing.  If a RECEIVE is satisfied,
  4433.         the user should be notified, with "end-of-letter" (EOL) signal,
  4434.         if appropriate.
  4435.  
  4436.       TIME-WAIT STATE
  4437.       CLOSE-WAIT STATE
  4438.  
  4439.         This should not occur, since a FIN has been received from the
  4440.         remote side.  Ignore the segment text.
  4441.  
  4442.     eighth, check the FIN bit,
  4443.  
  4444.       Send an acknowledgment for the FIN.  Signal the user "connection
  4445.       closing", and return any pending RECEIVEs with same message.  Note
  4446.       that FIN implies EOL for any segment text not yet delivered to the
  4447.       user.  If the current state is ESTABLISHED, enter the CLOSE-WAIT
  4448.       state.  If the current state is FIN-WAIT-1, enter the CLOSING
  4449.       state.  If the current state is FIN-WAIT-2, enter the TIME-WAIT
  4450.       state.
  4451.  
  4452.     and return.
  4453.  
  4454.  
  4455.  
  4456.  
  4457.  
  4458.  
  4459.  
  4460.  
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  
  4466.  
  4467.  
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476. [Page 72]                                                               
  4477.  
  4478.  
  4479. December 1979                                                           
  4480.                                            Transmission Control Protocol
  4481.                                                 Functional Specification
  4482. USER TIMEOUT
  4483.  
  4484.  
  4485.  
  4486.   USER TIMEOUT
  4487.  
  4488.     For any state if the user timeout expires, flush all queues, signal
  4489.     the user "error:  connection aborted due to user timeout" in general
  4490.     and for any outstanding calls, delete the TCB, and return.
  4491.  
  4492.   RETRANSMISSION TIMEOUT
  4493.  
  4494.     For any state if the retransmission timeout expires on a segment in
  4495.     the retransmission queue, send the segment at the front of the
  4496.     retransmission queue again, reinitialize the retransmission timer,
  4497.     and return.
  4498.  
  4499.    
  4500.  
  4501.  
  4502.  
  4503.  
  4504.  
  4505.  
  4506.  
  4507.  
  4508.  
  4509.  
  4510.  
  4511.  
  4512.  
  4513.  
  4514.  
  4515.  
  4516.  
  4517.  
  4518.  
  4519.  
  4520.  
  4521.  
  4522.  
  4523.  
  4524.  
  4525.  
  4526.  
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.  
  4533.  
  4534.  
  4535.                                                                [Page 73]
  4536.  
  4537.  
  4538.                                                            December 1979
  4539. Transmission Control Protocol
  4540.  
  4541.  
  4542.  
  4543.  
  4544.  
  4545.  
  4546.  
  4547.  
  4548.  
  4549.  
  4550.  
  4551.  
  4552.  
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558.  
  4559.  
  4560.  
  4561.  
  4562.  
  4563.  
  4564.  
  4565.  
  4566.  
  4567.  
  4568.  
  4569.  
  4570.  
  4571.  
  4572.  
  4573.  
  4574.  
  4575.  
  4576.  
  4577.  
  4578.  
  4579.  
  4580.  
  4581.  
  4582.  
  4583.  
  4584.  
  4585.  
  4586.  
  4587.  
  4588.  
  4589.  
  4590.  
  4591.  
  4592.  
  4593.  
  4594. [Page 74]                                                               
  4595.  
  4596.  
  4597. December 1979                                                           
  4598.                                            Transmission Control Protocol
  4599.  
  4600.  
  4601.  
  4602.                                 GLOSSARY
  4603.  
  4604.  
  4605.  
  4606. 1822
  4607.           BBN Report 1822, "The Specification of the Interconnection of
  4608.           a Host and an IMP".  The specification of interface between a
  4609.           host and the ARPANET.
  4610.  
  4611. ACK
  4612.           A control bit (acknowledge) occupying no sequence space, which
  4613.           indicates that the acknowledgment field of this segment
  4614.           specifies the next sequence number the sender of this segment
  4615.           is expecting to receive, hence acknowledging receipt of all
  4616.           previous sequence numbers.
  4617.  
  4618. ARPANET message
  4619.           The unit of transmission between a host and an IMP in the
  4620.           ARPANET.  The maximum size is about 1012 octets (8096 bits).
  4621.  
  4622. ARPANET packet
  4623.           A unit of transmission used internally in the ARPANET between
  4624.           IMPs.  The maximum size is about 126 octets (1008 bits).
  4625.  
  4626. buffer size
  4627.           An option (buffer size) used to state the receive data buffer
  4628.           size of the sender of this option.  May only be sent in a
  4629.           segment that also carries a SYN.
  4630.  
  4631. connection
  4632.           A logical communication path identified by a pair of sockets.
  4633.  
  4634. datagram
  4635.           A message sent in a packet switched computer communications
  4636.           network.
  4637.  
  4638. Destination Address
  4639.           The destination address, usually the network and host
  4640.           identifiers.
  4641.  
  4642. EOL
  4643.           A control bit (End of Letter) occupying no sequence space,
  4644.           indicating that this segment ends a logical letter with the
  4645.           last data octet in the segment.  If this end of letter causes
  4646.           a less than full buffer to be released to the user and the
  4647.           connection buffer size is not one octet then the
  4648.           end-of-letter/buffer-size adjustment to the receive sequence
  4649.           number must be made.
  4650.  
  4651.  
  4652.  
  4653.                                                                [Page 75]
  4654.  
  4655.  
  4656.                                                            December 1979
  4657. Transmission Control Protocol
  4658. Glossary
  4659.  
  4660.  
  4661.  
  4662. FIN
  4663.           A control bit (finis) occupying one sequence number, which
  4664.           indicates that the sender will send no more data or control
  4665.           occupying sequence space.
  4666.  
  4667. fragment
  4668.           A portion of a logical unit of data, in particular an internet
  4669.           fragment is a portion of an internet datagram.
  4670.  
  4671. FTP
  4672.           A file transfer protocol.
  4673.  
  4674. header
  4675.           Control information at the beginning of a message, segment,
  4676.           fragment, packet or block of data.
  4677.  
  4678. host
  4679.           A computer.  In particular a source or destination of messages
  4680.           from the point of view of the communication network.
  4681.  
  4682. Identification
  4683.           An Internet Protocol field.  This identifying value assigned
  4684.           by the sender aids in assembling the fragments of a datagram.
  4685.  
  4686. IMP
  4687.           The Interface Message Processor, the packet switch of the
  4688.           ARPANET.
  4689.  
  4690. internet address
  4691.           A source or destination address specific to the host level.
  4692.  
  4693. internet datagram
  4694.           The unit of data exchanged between an internet module and the
  4695.           higher level protocol together with the internet header.
  4696.  
  4697. internet fragment
  4698.           A portion of the data of an internet datagram with an internet
  4699.           header.
  4700.  
  4701. IP
  4702.           Internet Protocol.
  4703.  
  4704. IRS
  4705.           The Initial Receive Sequence number.  The first sequence
  4706.           number used by the sender on a connection.
  4707.  
  4708.  
  4709.  
  4710.  
  4711.  
  4712. [Page 76]                                                               
  4713.  
  4714.  
  4715. December 1979                                                           
  4716.                                            Transmission Control Protocol
  4717.                                                                 Glossary
  4718.  
  4719.  
  4720.  
  4721. ISN
  4722.           The Initial Sequence Number.  The first sequence number used
  4723.           on a connection, (either ISS or IRS).  Selected on a clock
  4724.           based procedure.
  4725.  
  4726. ISS
  4727.           The Initial Send Sequence number.  The first sequence number
  4728.           used by the sender on a connection.
  4729.  
  4730. leader
  4731.           Control information at the beginning of a message or block of
  4732.           data.  In particular, in the ARPANET, the control information
  4733.           on an ARPANET message at the host-IMP interface.
  4734.  
  4735. left sequence
  4736.           This is the next sequence number to be acknowledged by the
  4737.           data receiving TCP (or the lowest currently unacknowledged
  4738.           sequence number) and is sometimes referred to as the left edge
  4739.           of the send window.
  4740.  
  4741. letter
  4742.           A logical unit of data, in particular the logical unit of data
  4743.           transmitted between processes via TCP.
  4744.  
  4745. local packet
  4746.           The unit of transmission within a local network.
  4747.  
  4748. module
  4749.           An implementation, usually in software, of a protocol or other
  4750.           procedure.
  4751.  
  4752. MSL
  4753.           Maximum Segment Lifetime, the time a TCP segment can exist in
  4754.           the internetwork system.
  4755.  
  4756. octet
  4757.           An eight bit byte.
  4758.  
  4759. Options
  4760.           An Option field may contain several options, and each option
  4761.           may be several octets in length.  The options are used
  4762.           primarily in testing situations; for example, to carry
  4763.           timestamps.  Both the Internet Protocol and TCP provide for
  4764.           options fields.
  4765.  
  4766. packet
  4767.           A package of data with a header which may or may not be
  4768.  
  4769.  
  4770.  
  4771.                                                                [Page 77]
  4772.  
  4773.  
  4774.                                                            December 1979
  4775. Transmission Control Protocol
  4776. Glossary
  4777.  
  4778.  
  4779.  
  4780.           logically complete.  More often a physical packaging than a
  4781.           logical packaging of data.
  4782.  
  4783. port
  4784.           The portion of a socket that specifies which logical input or
  4785.           output channel of a process is associated with the data.
  4786.  
  4787. process
  4788.           A program in execution.  A source or destination of data from
  4789.           the point of view of the TCP or other host-to-host protocol.
  4790.  
  4791. PSN
  4792.           A Packet Switched Network.  For example, the ARPANET.
  4793.  
  4794. RCV.BS
  4795.           receive buffer size, the remote buffer size
  4796.  
  4797. RCV.LBB
  4798.           receive last buffer beginning
  4799.  
  4800. RCV.NXT
  4801.           receive next sequence number
  4802.  
  4803. RCV.UP
  4804.           receive urgent pointer
  4805.  
  4806. RCV.WND
  4807.           receive window
  4808.  
  4809. receive last buffer beginning
  4810.           This is the sequence number of the first octet of the most
  4811.           recent buffer.  This value is use in calculating the next
  4812.           sequence number when a segment contains an end of letter
  4813.           indication.
  4814.  
  4815. receive next sequence number
  4816.           This is the next sequence number the local TCP is expecting to
  4817.           receive.
  4818.  
  4819. receive window
  4820.           This represents the sequence numbers the local (receiving) TCP
  4821.           is willing to receive.  Thus, the local TCP considers that
  4822.           segments overlapping the range RCV.NXT to
  4823.           RCV.NXT + RCV.WND - 1 carry acceptable data or control.
  4824.           Segments containing sequence numbers entirely outside of this
  4825.           range are considered duplicates and discarded.
  4826.  
  4827.  
  4828.  
  4829.  
  4830. [Page 78]                                                               
  4831.  
  4832.  
  4833. December 1979                                                           
  4834.                                            Transmission Control Protocol
  4835.                                                                 Glossary
  4836.  
  4837.  
  4838.  
  4839. RST
  4840.           A control bit (reset), occupying no sequence space, indicating
  4841.           that the receiver should delete the connection without further
  4842.           interaction.  The receiver can determine, based on the
  4843.           sequence number and acknowledgment fields of the incoming
  4844.           segment, whether it should honor the reset command or ignore
  4845.           it.  In no case does receipt of a segment containing RST give
  4846.           rise to a RST in response.
  4847.  
  4848. RTP
  4849.           Real Time Protocol:  A host-to-host protocol for communication
  4850.           of time critical information.
  4851.  
  4852. Rubber EOL
  4853.           An end of letter (EOL) requiring a sequence number adjustment
  4854.           to align the beginning of the next letter on a buffer
  4855.           boundary.
  4856.  
  4857. SEG.ACK
  4858.           segment acknowledgment
  4859.  
  4860. SEG.LEN
  4861.           segment length
  4862.  
  4863. SEG.PRC
  4864.           segment precedence value
  4865.  
  4866. SEG.SEQ
  4867.           segment sequence
  4868.  
  4869. SEG.UP
  4870.           segment urgent pointer field
  4871.  
  4872. SEG.WND
  4873.           segment window field
  4874.  
  4875. segment
  4876.           A logical unit of data, in particular a TCP segment is the
  4877.           unit of data transfered between a pair of TCP modules.
  4878.  
  4879. segment acknowledgment
  4880.           The sequence number in the acknowledgment field of the
  4881.           arriving segment.
  4882.  
  4883. segment length
  4884.           The amount of sequence number space occupied by a segment,
  4885.           including any controls which occupy sequence space.
  4886.  
  4887.  
  4888.  
  4889.                                                                [Page 79]
  4890.  
  4891.  
  4892.                                                            December 1979
  4893. Transmission Control Protocol
  4894. Glossary
  4895.  
  4896.  
  4897.  
  4898. segment sequence
  4899.           The number in the sequence field of the arriving segment.
  4900.  
  4901. send last buffer beginning
  4902.           This is the sequence number of the first octet of the most
  4903.           recent buffer.  This value is use in calculating the next
  4904.           sequence number when a segment contains an end of letter
  4905.           indication.
  4906.  
  4907. send sequence
  4908.           This is the next sequence number the local (sending) TCP will
  4909.           use on the connection.  It is initially selected from an
  4910.           initial sequence number curve (ISN) and is incremented for
  4911.           each octet of data or sequenced control transmitted.
  4912.  
  4913. send window
  4914.           This represents the sequence numbers which the remote
  4915.           (receiving) TCP is willing to receive.  It is the value of the
  4916.           window field specified in segments from the remote (data
  4917.           receiving) TCP.  The range of sequence numbers which may be
  4918.           emitted by a TCP lies between SND.NXT and
  4919.           SND.UNA + SND.WND - 1.
  4920.  
  4921. SND.BS
  4922.            send buffer size, the local buffer size
  4923.  
  4924. SND.LBB
  4925.           send last buffer beginning
  4926.  
  4927. SND.NXT
  4928.           send sequence
  4929.  
  4930. SND.UNA
  4931.           left sequence
  4932.  
  4933. SND.UP
  4934.           send urgent pointer
  4935.  
  4936. SND.WL
  4937.           send sequence number at last window update
  4938.  
  4939. SND.WND
  4940.           send window
  4941.  
  4942. socket
  4943.           An address which specifically includes a port identifier, that
  4944.           is, the concatenation of an Internet Address with a TCP port.
  4945.  
  4946.  
  4947.  
  4948. [Page 80]                                                               
  4949.  
  4950.  
  4951. December 1979                                                           
  4952.                                            Transmission Control Protocol
  4953.                                                                 Glossary
  4954.  
  4955.  
  4956.  
  4957. Source Address
  4958.           The source address, usually the network and host identifiers.
  4959.  
  4960. SYN
  4961.           A control bit in the incoming segment, occupying one sequence
  4962.           number, used at the initiation of a connection, to indicate
  4963.           where the sequence numbering will start.
  4964.  
  4965. TCB
  4966.           Transmission control block, the data structure that records
  4967.           the state of a connection.
  4968.  
  4969. TCB.PRC
  4970.           The precedence of the connection.
  4971.  
  4972. TCP
  4973.           Transmission Control Protocol:  A host-to-host protocol for
  4974.           reliable communication in internetwork environments.
  4975.  
  4976. TOS
  4977.           Type of Service, an Internet Protocol field.
  4978.  
  4979. Type of Service
  4980.           An Internet Protocol field which indicates the type of service
  4981.           for this internet fragment.
  4982.  
  4983. URG
  4984.           A control bit (urgent), occupying no sequence space, used to
  4985.           indicate that the receiving user should be notified to do
  4986.           urgent processing as long as there is data to be consumed with
  4987.           sequence numbers less than the value indicated in the urgent
  4988.           pointer.
  4989.  
  4990. urgent pointer
  4991.           A control field meaningful only when the URG bit is on.  This
  4992.           field communicates the value of the urgent pointer which
  4993.           indicates the data octet associated with the sending user's
  4994.           urgent call.
  4995.  
  4996.           
  4997.  
  4998.  
  4999.  
  5000.  
  5001.  
  5002.  
  5003.  
  5004.  
  5005.  
  5006.  
  5007.                                                                [Page 81]
  5008.  
  5009.  
  5010.                                                            December 1979
  5011. Transmission Control Protocol
  5012.  
  5013.  
  5014.  
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.  
  5021.  
  5022.  
  5023.  
  5024.  
  5025.  
  5026.  
  5027.  
  5028.  
  5029.  
  5030.  
  5031.  
  5032.  
  5033.  
  5034.  
  5035.  
  5036.  
  5037.  
  5038.  
  5039.  
  5040.  
  5041.  
  5042.  
  5043.  
  5044.  
  5045.  
  5046.  
  5047.  
  5048.  
  5049.  
  5050.  
  5051.  
  5052.  
  5053.  
  5054.  
  5055.  
  5056.  
  5057.  
  5058.  
  5059.  
  5060.  
  5061.  
  5062.  
  5063.  
  5064.  
  5065.  
  5066. [Page 82]                                                               
  5067.  
  5068.  
  5069. December 1979                                                           
  5070.                                            Transmission Control Protocol
  5071.  
  5072.  
  5073.  
  5074.                                REFERENCES
  5075.  
  5076.  
  5077.  
  5078. [1]  Postel, J. (ed.), "DOD Standard Internet Protocol," Defense
  5079.      Advanced Research Projects Agency, Information Processing
  5080.      Techniques Office, IEN 123, December 1979.
  5081.  
  5082. [2]  Feinler, E. and J. Postel, ARPANET Protocol Handbook, Network
  5083.      Information Center, Stanford Research Institute, Menlo Park, CA,
  5084.      January 1978.
  5085.  
  5086. [3]  Dalal, Y. and C. Sunshine, "Connection Management in Transport
  5087.      Protocols," Computer Networks, Vol. 2, No. 6, pp. 454-473,
  5088.      December 1978.
  5089.  
  5090.  
  5091.  
  5092.  
  5093.  
  5094.  
  5095.  
  5096.  
  5097.  
  5098.  
  5099.  
  5100.  
  5101.  
  5102.  
  5103.  
  5104.  
  5105.  
  5106.  
  5107.  
  5108.  
  5109.  
  5110.  
  5111.  
  5112.  
  5113.  
  5114.  
  5115.  
  5116.  
  5117.  
  5118.  
  5119.  
  5120.  
  5121.  
  5122.  
  5123.  
  5124.  
  5125.                                                                [Page 83]
  5126.  
  5127.  
  5128.                                                            December 1979
  5129. Transmission Control Protocol
  5130.  
  5131.  
  5132.  
  5133.  
  5134.  
  5135.  
  5136.  
  5137.  
  5138.  
  5139.  
  5140.  
  5141.  
  5142.  
  5143.  
  5144.  
  5145.  
  5146.  
  5147.  
  5148.  
  5149.  
  5150.  
  5151.  
  5152.  
  5153.  
  5154.  
  5155.  
  5156.  
  5157.  
  5158.  
  5159.  
  5160.  
  5161.  
  5162.  
  5163.  
  5164.  
  5165.  
  5166.  
  5167.  
  5168.  
  5169.  
  5170.  
  5171.  
  5172.  
  5173.  
  5174.  
  5175.  
  5176.  
  5177.  
  5178.  
  5179.  
  5180.  
  5181.  
  5182.  
  5183.  
  5184. [Page 84]                                                               
  5185.  
  5186.